Fancy Mouse
- -|||
上一页 1 ··· 3 4 5 6 7 8 9 下一页
摘要: 直接做吧,没什么好说的了 #includeusing namespace std;int main(){ int n,i,j; while(cin>>n>>i>>j) { int c; //Line for(c=1;c1 && t2>1) t1--,t2--; while(t11) t1++,t2--; whi... 阅读全文
posted @ 2005-08-27 13:23 Fancy Mouse 阅读(269) 评论(1) 推荐(0)
摘要: 简单的格式处理。 #include#includeusing namespace std;int main(){ int a,b; while(cin>>a>>b) { cout 0) cout<<setw(6)<<b/10*a<<endl; cout<<"-------"<<endl; cout<<setw(7)<... 阅读全文
posted @ 2005-08-27 13:20 Fancy Mouse 阅读(293) 评论(1) 推荐(0)
摘要: 枚举搜索。当然用动态规划是最好的了。我的搜索办法是,先将所有石子放在一起,然后满堆和空堆的差就是石子总质量。接下来就一种状态一种状态搜索,每次搜索到把一个石子从原来那个堆移动到另一个堆以后,满堆和空堆的差就减去这个石子重量的2倍。搜索完毕,取最小的那个差值即可。 #includeusing namespace std;const int MAX = 20;void Stone(int curren... 阅读全文
posted @ 2005-08-27 13:19 Fancy Mouse 阅读(546) 评论(1) 推荐(0)
摘要: 一开始做这题时大脑短路……连用浮点数来表示都没想到,所以我的做法是取1~n的对数,然后加起来,再减去一个整数使那个浮点在1~2的范围内,pow10以后取个位,答案就出来了。后来想想,用浮点这题有可能也做得出来,不大可能出现误差的~ P.S. 今天刚刚发现浮点没法做。long double的范围只到10的4000多次,而100000!可以到10的450000多次!所以用浮点不现实的了~~ #incl... 阅读全文
posted @ 2005-08-21 21:15 Fancy Mouse 阅读(440) 评论(1) 推荐(0)
摘要: 又是一道简单的题,直接照题意编就是了 #includeusing namespace std;const int MAX = 250;int main(){ char buffer[MAX],text[MAX]; int p,t; while(cin.getline(buffer,MAX)) { for(p=t=0;p<250 && buffer[p]!='\... 阅读全文
posted @ 2005-08-21 21:03 Fancy Mouse 阅读(353) 评论(2) 推荐(0)
摘要: Maigo大牛有一句很经典的比喻:“一个2跟一个5反应生成一个0,因为2过量,所以照5算”没错,只要算1~n这n个数里面一共有多少5因子就可以了 #includeusing namespace std;int main(){ int n=0,zeros=0; while(cin>>n) { while(n>=5) { n/=5; ... 阅读全文
posted @ 2005-08-21 21:01 Fancy Mouse 阅读(357) 评论(1) 推荐(0)
摘要: 从字符串头上开始贪心,保证最优解比较字符的时候大于小于等于都表忘记考虑~~ #includeusing namespace std;void CutDigit(char num[],int index);void HeadCalc(char num[],int rest);int main(){ char num[260]; int rest; while(cin>>num>>r... 阅读全文
posted @ 2005-08-21 20:58 Fancy Mouse 阅读(421) 评论(1) 推荐(0)
摘要: 没什么好说的了,标准链表题。 #includeusing namespace std;class LinkedList{public: LinkedList* Next; int Number; int Password; void DeleteNext(); LinkedList* Append(int Number,int Password); Li... 阅读全文
posted @ 2005-08-21 20:52 Fancy Mouse 阅读(485) 评论(1) 推荐(0)
摘要: 可以用大数类存放末几位的数字。乘出来有0就舍去。这是我的代码:(用long long即64位整形变量来计算) #includeusing namespace std;int main(){ unsigned long long n,t,sum,temp; while(cin>>n) { for(t=temp=1,sum=0;t<=n;t++) { ... 阅读全文
posted @ 2005-08-21 20:49 Fancy Mouse 阅读(620) 评论(7) 推荐(0)
摘要: 此题有多种做法,直接数也行(枚举所有数然后判断有多少质数);或者维护一个质数列表,输入两个数以后搜索有几个质数。我用的是前者 #include#includeusing namespace std;int IsPrime(long Num);int main(){ long int n,m,sum; while(cin>>n>>m) { sum=0; ... 阅读全文
posted @ 2005-08-21 17:47 Fancy Mouse 阅读(588) 评论(4) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 9 下一页