上一页 1 ··· 4 5 6 7 8 9 下一页
摘要: 原题链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=105分析:各位数求和再模9.九的余数 1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 int m,k,i;char a[1000010];int count; 6 scanf("%d",&m); 7 while(m--) 8 { 9 count=0;10 scanf("%s",a);11 k=strlen(a);12 for(i=0;i< 阅读全文
posted @ 2013-05-31 22:11 EtheGreat 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=22素数求和问题 1 #include<stdio.h> 2 int S(int n) 3 {int i,b,f; 4 if(n==1)f=0; 5 else if(n==2)f=2; 6 else 7 { 8 for(i=2;i<n;i++) 9 {b=1;if(n%i==0)b=0;if(b==0)break;}10 if(b==1)f=n;else f=0;11 }12 return(f);13 }14 int main()15 {int m,n,a,s,i;16 阅读全文
posted @ 2013-05-31 22:07 EtheGreat 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=24分析:向两边分别找到第一个素数,再比较。素数距离问题 1 #include<stdio.h> 2 #include<math.h> 3 int p(int n) 4 { 5 int i,f=1; 6 if(n==0)return 0; 7 else if(n==1)return 0; 8 else if(n==2)return 1; 9 else10 {11 for(i=2;i<=sqrt(n);i++)12 ... 阅读全文
posted @ 2013-05-31 22:03 EtheGreat 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=6喷水装置(一) 1 #include<stdio.h> 2 int main() 3 { 4 int m,n,i,j,count;float str[610],p,temp; 5 scanf("%d",&m); 6 while(m--) 7 { 8 count=0;p=0; 9 scanf("%d",&n);10 for(i=0;i<n;i++)11 scanf("%f",&str[. 阅读全文
posted @ 2013-05-31 21:51 EtheGreat 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=5分析:代码比较长,用到了字典树。Binary String Matching 1 2 #include<cstdio> 3 #include<cstring> 4 #include<iostream> 5 using namespace std; 6 #define LEN sizeof(struct Trie) 7 typedef struct Trie 8 { 9 struct Trie *next[2]; 10 }Trie; 11 char B 阅读全文
posted @ 2013-05-31 21:40 EtheGreat 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=4ASCII码排序 1 #include<stdio.h> 2 int main() 3 { 4 int t;char str[3],temp,a,b,c; 5 scanf("%d",&t); 6 while(t--) 7 { 8 scanf("%s",str);a=str[0];b=str[1];c=str[2]; 9 if(a>b){temp=a;a=b;b=temp;}10 if(... 阅读全文
posted @ 2013-05-31 21:32 EtheGreat 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=2分析:从后面往前面扫描,遇到配对的就删去,否则保存在栈里,继续扫描时,检查其是否与栈顶元素配对。括号配对问题 1 2 #include<cstdio> 3 #include<cstring> 4 #include <stack> 5 #include <iostream> 6 using namespace std; 7 stack<char>d; 8 int main() 9 {10 int N,len,i,flag;11 阅读全文
posted @ 2013-05-31 21:27 EtheGreat 阅读(160) 评论(0) 推荐(0) 编辑
摘要: http://acm.uestc.edu.cn/problem.php?pid=1023 阅读全文
posted @ 2013-05-31 21:08 EtheGreat 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.uestc.edu.cn/problem.php?pid=1034锥形之阵 1 #include<stdio.h> 2 int main() 3 { 4 int t,n,i; 5 scanf("%d",&t); 6 while(t--) 7 { 8 scanf("%d",&n); 9 for(i=1;(i+1)*(i+1)/4<=n;i=i+2);10 i=i-2;11 printf("%d\n",(i+1)*(i+1)/4);12 }13 retur... 阅读全文
posted @ 2013-05-31 21:02 EtheGreat 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.uestc.edu.cn/problem.php?pid=1060分析:画出图形,分三种情况找公式。锥形之阵之变阵 1 #include<stdio.h> 2 int main() 3 { 4 int t,n,k;long m; 5 scanf("%d",&t); 6 while(t--) 7 { 8 scanf("%d",&n); 9 k=n/3;10 if(n%3==0)m=3*k*(k+1)/2-k;11 else if(... 阅读全文
posted @ 2013-05-31 20:58 EtheGreat 阅读(119) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 下一页