poj水题若干道
2014-07-15 21:35
204 查看
poj1033 Hangover
题目链接:http://poj.org/problem?id=1003
poj1004 Financial Management
题目链接:http://poj.org/problem?id=1004
poj1005 I Think I Need a Houseboat
题目链接:http://poj.org/problem?id=1005
poj1207 The 3n + 1 problem
题目链接:http://poj.org/problem?id=1207
poj3299 Humidex
题目链接:http://poj.org/problem?id=3299
poj2159 Ancient Cipher
题目链接:http://poj.org/problem?id=2159
思路:只要原字符串跟加密之后的字符串能够一一对应,并且每个字符对应的字符不同即可。
poj3094 Quicksum 很水很水
题目链接:http://poj.org/problem?id=3094
题目链接:http://poj.org/problem?id=1003
///2014.7.15 ///poj1003 //Accepted 740K 0MS G++ 385B 2014-07-15 19:58:59 //题目大意:已知c=1/2+1/3+1/4+....1/(n+1).现给出一个值m,求n的值使得c刚好超过m。 #include <iostream> #include <cstdio> #include <cstring> using namespace std; int main(){ double num; double sum; int n; while( cin>>num && num!=0 ){ n = 2; sum = 0; while( sum < num ){ sum += 1.0/n; n++; } printf("%d card(s)\n",n-2 ); } return 0; }
poj1004 Financial Management
题目链接:http://poj.org/problem?id=1004
///2014.7.15 ///poj1004 //题目大意:给出12个数,求这12个数的平均数。 #include <iostream> #include <cstdio> #include <cstring> using namespace std; int main(){ double sum = 0; double num; int n = 12; while( n-- ){ cin>>num; sum += num; } cout<<"$"<<sum/12<<endl; return 0; }
poj1005 I Think I Need a Houseboat
题目链接:http://poj.org/problem?id=1005
///2014.7.15 ///poj1005 //题目大意:已知一个圆心为(0,0), //半径随时间增长的位于X轴上方的半圆, //初始面积为0,每年的面积增加50,给出一个坐标 //求该坐标在第几年被该半圆覆盖。 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; int main(){ // freopen("in","r",stdin); // freopen("out","w",stdout); int cas = 0; int t; scanf("%d",&t); double x,y,Area; while( t-- ){ cas++; cin>>x>>y; Area = (x*x+y*y) * 3.141592654 / 2; int n = 0; while( n*50 < Area ) n++; cout<<"Property "<<cas<<": This property will begin eroding in year "<<n<<"."<<endl; } cout<<"END OF OUTPUT."<<endl; return 0; }
poj1207 The 3n + 1 problem
题目链接:http://poj.org/problem?id=1207
///2014.7.15 ///poj1207 // 大致题意: // 根据给定的算法,可以计算一个整数的循环数 // 现在给定一个区间,计算这个区间的所有数的循环数,把最大的循环数输出 // PS:输出的是整数A的循环数,而不是输出整数A #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; int cnum(int i){ int re = 1; while( i!=1 ){ if( i%2 ) i = i*3+1; else i = i/2; re++; } return re; } int main(){ // freopen("in","r",stdin); // freopen("out","w",stdout); int a,b; int maxcnum; while( cin>>a>>b ){ int x=a<b?a:b; int y=a>b?a:b; maxcnum = 0; for(int i=x ; i<=y ; i++){ int temp = cnum(i); if( temp > maxcnum ) maxcnum = temp; } cout<<a<<' '<<b<<' '<<maxcnum<<endl; } return 0; }
poj3299 Humidex
题目链接:http://poj.org/problem?id=3299
#include <iostream> #include <math.h> #include <string> #include <iomanip> using namespace std; int main(){ char alpha; double t,d,h; int i; while( true ){ t=d=h=200; for(i=0;i<2;i++) { cin>>alpha; if(alpha=='E') return 0; else if(alpha=='T') cin>>t; else if(alpha=='D') cin>>d; else if(alpha=='H') cin>>h; } if( h == 200 ) h=t+0.5555*(6.11*exp(5417.7530*(1/273.16-1/(d+273.16)))-10); else if(t==200) t=h-0.5555*(6.11*exp(5417.7530*(1/273.16-1/(d+273.16)))-10); else if(d==200) d=1/((1/273.16)-((log((((h-t)/0.5555)+10.0)/6.11))/5417.7530))-273.16; cout<<setprecision(1)<<fixed<<"T "<<t<<" D "<<d<<" H "<<h<<endl; } return 0; }
poj2159 Ancient Cipher
题目链接:http://poj.org/problem?id=2159
思路:只要原字符串跟加密之后的字符串能够一一对应,并且每个字符对应的字符不同即可。
///2014.7.16 ///poj2159 //Accepted 704K 63MS G++ 797B 2014-07-16 09:45:12 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; int main(){ // freopen("in","r",stdin); // freopen("out","w",stdout); string x,y; char xnum[26],ynum[26]; for(int i=0 ; i<26 ; i++) xnum[i] = ynum[i] = 0; cin>>x>>y; for(int i=0 ; i<x.length() ; i++) xnum[ x[i]-'A' ] ++; for(int i=0 ; i<y.length() ; i++) ynum[ y[i]-'A' ] ++; sort(xnum,xnum+26); sort(ynum,ynum+26); bool can = true; for(int i=0 ; i<26 ; i++){ if( xnum[i] != ynum[i] ){ can = false; break; } } if( can ) cout<<"YES"<<endl; else cout<<"NO"<<endl; return 0; }
poj3094 Quicksum 很水很水
题目链接:http://poj.org/problem?id=3094
///2014.7.17 ///poj3094 //Accepted 380K 0MS G++ 454B 2014-07-17 16:02:43 #include <cstdio> char temp; int sum; int main(){ while( ~scanf("%c",&temp) && temp!='#' ){ int i=1; sum = 0; while( temp==' ' || ( temp<='Z' && temp>='A' ) ){ if( temp<='Z' && temp>='A' ) sum += (i++) * ( temp-'A'+1 ); else i++; scanf("%c",&temp); } printf("%d\n",sum ); } return 0; }
相关文章推荐
- poj 2356鸽笼原理水题
- poj 1005 水题
- POJ 2665 水题
- poj1028~无聊但是慢慢增加信心的水题
- POJ 2774 后缀数组水题
- POJ 3087 Shuffle'm Up(水题)
- 基本算法floyd的poj水题推荐
- POJ 2739 Sum of Consecutive Prime Numbers(素数打表水题)
- poj2159 对我来说不是水题的水题
- poj 1207 水题
- poj 1298(水题)
- poj2663 Tri Tiling dp 水题
- POJ 1218 THE DRUNK JAILER(水题)
- POJ 1493 Machined Surfaces(我的水题之路——移动后的空格)
- POJ 2000 Glod Conins(我的水题之路——之后的N天N个金币,打表)
- LA 3026 POJ 1961 KMP水题
- POJ 1067(广搜水题)
- POJ 2350 Above Average(我的水题之路——%lf输出报错)
- POJ 2578 Keep on Truckin'(我的水题之路——谁先大于168)
- POJ 3117 World Cup(我的水题之路——世界杯平局数目)