摘要: #include#include#include#define N 1000005using namespace std;int position[N];int main(){ memset(position,0,sizeof(position)); position[1]=0; int next=1; int i,j; for(i=2;i<N;i++) { if(position[i]) continue; for(j=i;j<N;j+=i) { position[j]=next; } next++; } int m; while(scanf("%d",&am 阅读全文
posted @ 2012-04-28 21:54 剑不飞 阅读(423) 评论(0) 推荐(0) 编辑
摘要: How many prime numbersTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3302 Accepted Submission(s): 1074Problem DescriptionGive you a lot of positive integers, just to find out how many prime numbers there are.InputThere are a lot of cases. In eac. 阅读全文
posted @ 2012-04-28 20:35 剑不飞 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 公式 p+q-gcd(p,q)就是所求值#include#include#includeusing namespace std;int gcd(int n,int m){ if(m==0) return n; gcd(m,n%m);}int main(){ int m,n; while(cin>>m>>n) { cout<<m+n-gcd(m,n)<<endl; }} 阅读全文
posted @ 2012-04-28 17:48 剑不飞 阅读(86) 评论(0) 推荐(0) 编辑
摘要: Transformations A square pattern of size N x N (1 #include #include #include #define N 15 using namespace std; char map[N][N]; char _map[N][N]; int main() { freopen("transform.in","r",stdin); freopen("transform.out","w",stdout); int m; while(scanf("%d&quo 阅读全文
posted @ 2012-04-28 13:48 剑不飞 阅读(137) 评论(0) 推荐(0) 编辑