poj水题若干道
来源:互联网 发布:usleep函数 windows 编辑:程序博客网 时间:2024/05/13 03:26
poj1033 Hangover
题目链接: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;}
0 0
- poj水题若干道
- POJ 水题若干
- POJ 水题若干
- 若干题
- 若干C笔试题
- 数论若干题
- 若干笔试题
- 若干面试概率题
- 状态dp若干入门题
- poj 2833 堆的应用(去若干最大值最小值)
- poj 1113 凸包(若干点外建围墙)
- poj 1226 hdu 1238 Substrings 求若干字符串正串及反串的最长公共子串 2002亚洲赛天津预选题
- 若干道笔试试题,基础加经典
- 组合数学之排列组合若干题
- codeforces C题若干只[round1]
- 矩阵总结(矩阵若干类型题)
- //求一个串最多由哪个串复制若干次得到 poj 2406
- POJ 3695 容斥原理求若干矩形并 (n <= 20)
- linuxc一站式编程中的汇编整理
- PKU3625Prime
- ArraList的用法
- hdu1506 Largest Rectangle
- APN远程推送
- poj水题若干道
- 原码 补码 反码
- java写代码1——众数问题
- java 各种乱码情况分析
- 【HDU】3394 Railway 点双连通求块
- linux Mint 17(ubuntu)下angularjs开发环境配置
- MyBatis3整合Spring3_SpringMVC
- mac编译cocos2d-x-3.2*的android工程报错
- 黑马程序员:IO流