摘要: 原题链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=106分析:排序加贪心。背包问题 1 #include 2 int main() 3 { 4 int n,s,m,i,j,value,temp;int str[11][2]; 5 scanf("%d",&n); 6 while(n--) 7 { 8 value=0; 9 scanf("%d%d",&s,&m);10 for(i=0;i<s;i++)11 scanf("%d%d",&st... 阅读全文
posted @ 2013-05-31 22:31 EtheGreat 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=44分析:经典DP。子串和 1 #include 2 long long T,num,front,i,n,ans; 3 long long max(long long x,long long y) 4 { 5 if(x>y)return x; 6 return y; 7 } 8 int main() 9 {10 scanf("%lld",&T);11 while(T--)12 {13 scanf("%lld",&n);14 . 阅读全文
posted @ 2013-05-31 22:21 EtheGreat 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=68分析:有向图。三点顺序 1 #include 2 int main() 3 { 4 int x1,y1,x2,y2,x3,y3,p;long s; 5 while(scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3)==6) 6 { 7 if(x1==0&&y1==0&&x2==0&&y2==0&&x3==0& 阅读全文
posted @ 2013-05-31 22:17 EtheGreat 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 原题链接: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) 编辑
摘要: 原题链接:http://acm.uestc.edu.cn/problem.php?pid=1256分析:能被11整除的数具有什么特性呢?原来是奇数位与偶数位之差的绝对值是11的倍数。能被3和11整除吗 1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 int t,s,s1,s2,s3,i; 6 char a[210]; 7 scanf("%d",&t); 8 while(t--) 9 {10 s=s1=s2=0;11 scanf("%s",a);12 . 阅读全文
posted @ 2013-05-31 20:48 EtheGreat 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.uestc.edu.cn/problem.php?pid=1816 阅读全文
posted @ 2013-05-31 20:36 EtheGreat 阅读(245) 评论(0) 推荐(1) 编辑
摘要: 原题链接:http://acm.uestc.edu.cn/problem.php?pid=1846分析:设置front记录前一个单词即可,容易题。Angry Grammar Nazi 1 #include<stdio.h> 2 #include<string.h> 3 int lol(char string[105]) 4 { 5 int i,len; 6 len=strlen(string); 7 for(i=0;i<len-2;i++) 8 { 9 if(string[i]=='l'&&string[i+1]=='o&# 阅读全文
posted @ 2013-05-31 20:27 EtheGreat 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.uestc.edu.cn/problem.php?pid=1849分析:设置一个ori变量记录房间里原有人数。Negative People in Da House 1 #include<stdio.h> 2 int main() 3 { 4 int T,t,M,a,b,i,ori,sum; 5 scanf("%d",&T); 6 while(T--) 7 { 8 sum=0;ori=0; 9 scanf("%d",&M);10 for(i=1;i<=M;i++)11 ... 阅读全文
posted @ 2013-05-31 20:18 EtheGreat 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.uestc.edu.cn/problem.php?pid=1850 1 #include<cstdio> 2 #include<algorithm> 3 #include<iostream> 4 using namespace std; 5 int main() 6 { 7 int T,W,M,num[105],ans,i,flag; 8 scanf("%d",&T); 9 while(T--)10 {11 ans=0;flag=0;12 scanf("%d %d",&W 阅读全文
posted @ 2013-05-31 20:12 EtheGreat 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.uestc.edu.cn/problem.php?pid=1852分析:分情况讨论即可。 1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 int T,x,y,i,j,temp; 6 char cell[105][105]; 7 scanf("%d",&T); 8 while(T--) 9 {10 scanf("%d%d",&x,&y);11 getchar();12 memset(cell,0,sizeo 阅读全文
posted @ 2013-05-31 20:05 EtheGreat 阅读(162) 评论(0) 推荐(0) 编辑