hdu 2015
两次错
1、被零除;忽略了模会出现0
2、输出有误,行末没有空格,在第一次之后,每次输出数之前输出空格。
#include<bits/stdc++.h> using namespace std; int isSU(int n){ if(n < 2) return 0; if(n == 2) return 1; if(n%2 == 0) return 0; int m = sqrt(n),i; for(i = 3;i <= m;i+=2){ if(n%i == 0) break; } return i > m ? 1 : 0; } int main() { int n,m; while(scanf("%d %d",&n,&m)!=EOF){ int x = n / m; int y = n % m; int t = m+1; for(int i = 0;i < x;i++){ if(i) printf(" "); printf("%d",t); t+=2*m; } int sum = 0; for(int i = 2 * n;i > 2 * (n - y);i-=2){ sum += i; } if(y){ sum/=y; printf(" %d\n",sum); }else{ printf("\n"); } } return 0; }