随笔分类 -  acm

uva 107 - The Cat in the Hat
摘要:自己的写的太丑了,看了网上的才叫惊呆,太挫了用log做太简单了。。。 1 #include 2 #include 3 void main() 4 {int hight,num,left,right,mid,x,y; 5 while (scanf("%d%d",&hight,&num),hight+num) 6 { 7 left=1; right=10000000; 8 while (left) 9 {mid=(left+right)/2;10 if (fabs(log(mid)*log(hight)-log(mid+1)*log(num))0) right= 阅读全文

posted @ 2014-01-07 17:15 云在心 阅读(182) 评论(0) 推荐(0)

uva 591 - Box of Bricks
摘要:水题 1 #include 2 using namespace std; 3 int main(){ 4 int n; 5 int h[101]; 6 int temp=1; 7 while(cin>>n){ 8 int sum=0; 9 if(n==0)10 break;11 for(int i=0;i>h[i];13 sum+=h[i];14 }15 int ave=sum/n;16 sum=0;17 ... 阅读全文

posted @ 2014-01-03 16:11 云在心 阅读(113) 评论(0) 推荐(0)

uva 10025 - The ? 1 ? 2 ? ... ? n = k problem
摘要:这题乍看很难,其实一想就通了只要1+。。+n>=k这时候要填符号,就是 减去双倍的某个数所以1+..n减去k必为偶数 1 #include 2 #include 3 using namespace std; 4 int main(){ 5 int n; 6 cin>>n; 7 while(n--){ 8 int k; 9 cin>>k;10 if(k==0){11 cout=2*k&&((i+1)*i/2-k)%2==0){19 cout0)24 ... 阅读全文

posted @ 2014-01-03 15:56 云在心 阅读(102) 评论(0) 推荐(0)

uva 621 - Secret Research
摘要:水题不多说 1 #include 2 #include 3 #include 4 using namespace std; 5 int main(){ 6 int n; 7 cin>>n; 8 getchar(); 9 while(n--){10 string l;11 getline(cin,l);12 if(l=="1"||l=="4"||l=="78"){13 cout<<"+"<<endl;14 }15 else if(l[l.size()-1]=='... 阅读全文

posted @ 2014-01-03 14:32 云在心 阅读(107) 评论(0) 推荐(0)

uva 10161 - Ant on a Chessboard
摘要:这题很简单,记得输出是x y不是(x,y),还wa了一次 1 #include 2 #include 3 using namespace std; 4 int main(){ 5 int n; 6 while(cin>>n){ 7 if(n==0) 8 break; 9 if(n==1){10 coutnth*nth)?(nth+1):nth;15 int flag=nth%2;16 int temp=n-(nth-1)*(nth-1)-nth;17 ... 阅读全文

posted @ 2014-01-02 21:46 云在心 阅读(111) 评论(0) 推荐(0)

uva 10785 - The Mad Numerologist
摘要:这题就是计算元音和辅音的个数,放到两个容器里,再按字典序排序一开始漏写了个辅音,错了一次 1 #include 2 #include 3 #include 4 using namespace std; 5 int main(){ 6 int n; 7 cin>>n; 8 vector v_vowel; 9 vector v_consonants;10 char vowel[5]={'A','U','E','O','I'};11 char consonants[21]={'J',' 阅读全文

posted @ 2014-01-02 20:57 云在心 阅读(137) 评论(0) 推荐(0)

uva 755 - 487--3279
摘要:算法是蛮简单的,不过超时了 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 vector v_number; 9 vector v_num;10 int main(){11 int n;12 cin>>n;13 string l;14 getchar();15 char CmapN[100];16 CmapN['A']=CmapN['B']=CmapN['C']='2';17 CmapN 阅读全文

posted @ 2014-01-02 19:32 云在心 阅读(290) 评论(0) 推荐(0)

uva 10194 - Football (aka Soccer)
摘要:又是wa,有点搞不懂 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 typedef struct infoteam{ 9 string name; 10 int games; 11 int point; 12 int win; 13 int tie; 14 int lose; 15 int difference; 16 int score; 17 int against;... 阅读全文

posted @ 2013-12-31 10:42 云在心 阅读(196) 评论(0) 推荐(0)

uva 123 - Searching Quickly
摘要:这题是wa,现在没时间改,应该是单词搜寻那里有问题,搜th,the也能搜到 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 typedef struct combine{ 8 string word; 9 int i;10 string replaceword;11 bool operator dictionnary;23 int main(){24 vector igwords;25 vector sentence;26 s... 阅读全文

posted @ 2013-12-30 19:24 云在心 阅读(127) 评论(0) 推荐(0)

uva 400 - Unix ls
摘要:这题其实很简单,但是re了很多次,因为天真到用setw,以及cout 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 int main(){10 int n;11 vector words;12 while(cin>>n){13 getchar();14 string l;15 int max=0;16 for(int i=0;i0)?(n/columnnum+1):(n/c... 阅读全文

posted @ 2013-12-26 21:48 云在心 阅读(166) 评论(0) 推荐(0)

uva 156 - Ananagrams
摘要:思路:1.先读取单词,把单词都整齐一下,从大写变为小写2.把单词按字母进行排序3.判断接下来的单词和前面的单词是否重复 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 vector newwords; 8 vector num; 9 vector oldwords;10 int main(){11 string l;12 vector::iterator it;13 while(getline(cin,l)){14 if(l[0]=='#... 阅读全文

posted @ 2013-12-26 20:12 云在心 阅读(191) 评论(0) 推荐(0)

uva 120 - Stacks of Flapjacks (RE)
摘要:一直runtime error,这题要注意,有可能数字是重复的。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 vector q_numb; 8 int len; 9 void q_sort(vector &numb){10 int max=0,pos=0,i=0;11 for(vector::iterator it=numb.begin();it!=numb.end();it++,i++){12 if(max(temp.c_str())));43... 阅读全文

posted @ 2013-12-26 14:41 云在心 阅读(142) 评论(0) 推荐(0)

uva 299 - Train Swapping
摘要:水题。。。 1 #include 2 using namespace std; 3 int main(){ 4 int n; 5 int num[51]; 6 cin>>n; 7 while(n--){ 8 int l,cishu=0; 9 cin>>l;10 for(int i=0;i>num[i];12 for(int i=0;inum[j]){15 int temp=num[i];16 num[i]=num[j];... 阅读全文

posted @ 2013-12-25 20:37 云在心 阅读(190) 评论(0) 推荐(0)

uva 152 Tree's a Crowd
摘要:突然不能登了,玩了局dota,编了这题,这题还是比较简单,英语拙计啊 1 #include 2 #include 3 #include 4 using namespace std; 5 int x[5010],y[5010],z[5010]; 6 int main(){ 7 int num=0,a[10]; 8 for(int i=0;i>x[num]>>y[num]>>z[num]){11 if(!x[num]&&!y[num]&&!z[num])12 break;13 num++;14 }15 for(... 阅读全文

posted @ 2013-12-25 17:04 云在心 阅读(116) 评论(0) 推荐(0)

uva 10474 Where is the Marble?
摘要:排序而已。。。。不过时间有点长,以后再考虑考虑怎么写 1 #include 2 #include 3 #include 4 using namespace std; 5 vector num; 6 int main(){ 7 int n,q,cishu=1; 8 vector::iterator result; 9 while(cin>>n>>q){10 if(!n&&!q)11 break;12 int temp;13 for(int i=0;i>temp;15 num.p... 阅读全文

posted @ 2013-12-25 14:12 云在心 阅读(134) 评论(0) 推荐(0)

uva 10420 - List of Conquests
摘要:这题写的好丑啊,这题感觉就是烦1.先要把单词读到一个数组,并记录次数2.对单词进行排序虽然只有0.022s,感觉写的太丑了不过这题温习了一下vector的用法,还有qsort的用法 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define MIN(a,b) ((a)>(b))?(b):(a) 9 using namespace std;10 vector v_word;11 vector v_num;12 typedef struct Node{13 string s;.. 阅读全文

posted @ 2013-12-25 13:44 云在心 阅读(186) 评论(0) 推荐(0)

uva 340 Master-Mind Hints
摘要:这题就是判断,先判断正确的,再判断位置不对但是数字对的这题开始提交都是 runtime error因为数组开的太小了,以后开大点。 1 #include 2 using namespace std; 3 int same,diff; 4 void juge(int len,int a[],int b[]){ 5 int tempa[1000],tempb[1000]; 6 same=0,diff=0; 7 for(int i=0;i>n){31 if(n==0)32 break;33 for(int i=0;i>a... 阅读全文

posted @ 2013-12-23 20:43 云在心 阅读(283) 评论(2) 推荐(0)

uva 748 - Exponentiation
摘要:这是计算指数的,刚开始不知道该怎么做,然后查看了一些网上的代码,只要把小数点去掉后,接下来就是大数相乘了我在做的时候一下几点要注意1.小数点位数要记住2.像0.0100后面的两个0应该去掉在做的时候还wa了一次,主要是格式没对,它要求前置0和后尾0 都去掉下面给出accept的代码 1 #include 2 #include 3 using namespace std; 4 #define MAXN 300 5 struct bign{ 6 int len,s[MAXN]; 7 bign(){ 8 len=1; 9 for(int i=0;i=... 阅读全文

posted @ 2013-12-23 12:22 云在心 阅读(183) 评论(0) 推荐(0)

uva 465 - Overflow
摘要:这题自己写的太菜了,看了网上的代码,受到很大的启发,有时候大数不一定要用数组,可以用很多方式来替换,一定要多思考,固定思维就是死路。本文代码出处http://blog.csdn.net/zcube/article/details/8458888 1 #include 2 3 const int MINT = 0x7fffffff; 4 5 int main() { 6 7 char str1[1000], str2[1000], ch; 8 9 while (scanf("%s %c %s", str1, &ch, str2) != EOF) {10 11 ... 阅读全文

posted @ 2013-12-19 14:01 云在心 阅读(134) 评论(0) 推荐(0)

uva 10106 - Product
摘要:这一题是大数相乘,还是用了刘汝佳老师的方法,下面提供两个大数相乘的算法bign operator *(const bign& b){ bign c; c.len=len+b.len; for(int i=0;i#include#includeusing namespace std;#define MAXN 600class bign{public: int len,s[MAXN]; bign(){ for(int i=0;i=0;i--,j++) this->s[j]=s[i]-'0'; } ... 阅读全文

posted @ 2013-12-18 21:25 云在心 阅读(107) 评论(0) 推荐(0)

导航