- 博客(18)
- 收藏
- 关注
原创 UVA 12100
#include#include#include#include#include#include using namespace std;typedef struct Job{ int pr; bool flag;}Job;int main(){ int T;cin >> T; while (T--) { queue q; priority_queue p
2017-07-29 00:19:38 293
原创 UVA 1595
#include#include#include#include#include using namespace std;typedef struct Pos{ int x; int y; bool operator < (const Pos& p) const { {} return x > p.x; } bool operator == (const
2017-07-28 14:24:28 407
原创 UVA 10391
#include#include#include#define setfind(y) words.find(y)!=words.end()using namespace std;set words;int main(){ string str; set::iterator it; while (cin >> str)words.insert(str); for (it = w
2017-07-28 11:18:32 369
原创 UVA 10935
简单队列模拟#include#include#includeusing namespace std;int main(){ int N; while (cin >> N&&N) { cout << "Discarded cards:"; queue q; for (int i = 1;i <= N;i++)q.push(i); bool first = tru
2017-07-27 22:57:38 353
原创 UVA 1594
#include#includeusing namespace std;int abs(int n) { return n>0 ? n : -n;}int main(){ int T;cin>>T; while (T--) { int t, n;cin >> t; vector v; while (t--) { cin >> n;v.push_back(
2017-07-27 22:56:27 345
转载 UVA 1593
原文http://blog.csdn.net/a197p/article/details/43465333初学stl,istringstream和getline的各种用法还是见得太少//#define LOCAL #include #include #include #include #include #include #includ
2017-07-26 17:29:23 377
原创 兰顿蚂蚁
#include<iostream>#include<algorithm>using namespace std;bool mp[100][100];int dir,x,y;void Move(){ int tx=x,ty=y; if(mp[x][y]==1) { if(dir==1){dir=4;y+=1;} else if(dir==2)...
2017-07-17 14:36:21 445
原创 UVA 11292
#include#include#include#includeusing namespace std;int main(){ int N,M,x,golds,i,j,cur; bool flag; while(cin>>N>>M&&N&&M) { vector heads,knights; golds=0;flag=false;cur=0; for(i=1;i>x
2017-07-14 15:54:06 249
原创 UVA 253 枚举
乍一看是三维问题,但是可以用字符串转成一维问题。题目要求是等价,那就看旋转后是否一样,有三种旋转方式,x,y,z轴有4*4*4个旋转情况。所以直接的思路就是三重循环,枚举三种旋转方式#include#includechar s[8];void c1(){ char t; t=s[2]; s[2]=s[3]; s[3]=s[5]; s[5]=s[4]; s[4]=
2017-07-12 15:32:44 313
原创 UVA 10340
#include#includeint main(){ int top,len; char s[100000],t[100000]; while(scanf("%s %s",s,t)!=EOF) { top=0; len=strlen(s); for(int i=0;i<strlen(t);i++) if(t[i]==s[top])top++; pr
2017-07-09 19:35:28 305
原创 UVA 455 暴力枚举
#include#includeint main(){ char s[80]; int T,i,j; scanf("%d",&T); while(T--) { bool found=false; scanf("%s",s); int len=strlen(s); for(i=1;i<=len/2;i++)//找因数,每个小于len/2的因数都
2017-07-08 16:48:02 527
原创 UVA 1225
#include#includeint main(){ int total[10],T; scanf("%d",&T); while(T--) { int n,i; scanf("%d",&n); memset(total,0,sizeof(total)); for(i=1;i<=n;i++) { int t=i; while(t){tot
2017-07-08 15:49:10 444
原创 UVA 1586
#include#include#includeint main(){ char s[100]; int T; scanf("%d",&T); while(T--) { scanf("%s",&s); double elem,sum=0; int count=0,i,power=0; bool single=true; for(i=strlen(s)-1
2017-07-08 14:54:54 294
原创 UVA 1585
#include#includeint main(){ char s[80]; int T; scanf("%d",&T); while(T--) { scanf("%s",s); int sum=0,score=0,i; for(i=0;i<strlen(s);i++) { if(s[i]=='O')score++; el
2017-07-08 14:08:03 269
原创 UVa 1584 求余实现环状串
#include#includechar s[100];int Less(int a,int b){ int len=strlen(s); for(int i=0;i<len;i++) { if(s[(a+i)%len]!=s[(b+i)%len]) return s[(a+i)%len]<s[(b+i)%len]?a:b; } return 0;}in
2017-07-07 23:49:05 390
原创 UVA 1583 打表 数论
#include "stdafx.h"#include "iostream"using namespace std;int _tmain(int argc, _TCHAR* argv[]){int hash[10001];memset(hash,0,sizeof(hash));for(int m=2000;m>=1;m--){ int x=m,y=m;w
2017-07-07 22:49:48 398
原创 UVA-340 Master-Mind Hints
#include#includeint main(){ int answer[1000],guess[1000]; int n,gameRounds=1; while(scanf("%d",&n)!=EOF&&n!=0) { int i; printf("Game %d:\n",gameRounds++); for(i=0;i<n;i++)
2017-07-04 19:27:00 258
原创 UVA401 字符串技巧
题干很清楚,镜像和回文都是通过对字符串的头尾依次判断在一定条件下是否相等,主要就是一个for循环 for(int i=0;i{ if(function(str[i])!=str[strlen(str)-i-1])bool **=false;}不过镜像串可能有点麻烦,可以用两个辅助数组来存储这两组信息,一个是未镜像字符,一个是对应的镜像字符。char unMirror
2017-07-04 15:48:23 349
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人