做了一天水题,挑几个还算凑合的发上来。

POJ1008 Maya Calendar

分析:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath> using namespace std; char Haab[][] = {"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol",
"chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu", "uayet"}; char Tzo[][] = {"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat",
"muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"}; int main() {
int year, day, cnt, month;
char szmonth[];
int T; scanf("%d", &T); printf("%d\n", T);
for(int k=; k<T; k++) {
scanf("%d.%s%d", &day, szmonth, &year); for(int i=; i<; i++) if(strcmp(Haab[i], szmonth) == ) month = i; cnt = year*+month*+day+; int ty=, td=, tm=; ty=(cnt-+)/-;
tm=(cnt-+)%;
td=(cnt-+)%+; printf("%d %s %d\n", td, Tzo[tm], ty);
} return ;
}

POJ1013 Counterfeit Dollar

分析:

超级暴力:分别对A~L这12个字母枚举轻重两种情况。

#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; char _left[][], _right[][], cond[][]; int cmp(char s1[], char s2[], int k, int j) {
/*
* 用来比较天平的平衡
* 右边up 返回 1
* 平衡 返回 0
* 右边down 返回 -1
*/
int len = strlen(s1);
int lef, rig;
lef = rig = ; for(int i=; i<len; i++) {
if(s1[i] == 'A'+k) lef += j;
if(s2[i] == 'A'+k) rig += j;
} if(lef < rig) return ;
else if(lef == rig) return ;
else return -;
} int main(){
int T, i, c, j;
scanf("%d", &T); while(T--) {
for(i=; i<; i++) {
scanf("%s %s %s", _left[i], _right[i], cond[i]);
} for(i=; i<; i++) { //分别枚举12个字母
for(j=-; j<=; j++) { //轻重两种情况
if(j==) continue; for(c=; c<; c++) { //三组
int res = cmp(_left[c], _right[c], i, j);
if( ! ((res == && cond[c][] == 'u') ||
(res == && cond[c][] == 'e') ||
(res == - && cond[c][] == 'd')))
break;
}
if(c >= ) break;
}
if(c >= ) break;
} printf("%c is the counterfeit coin and it is ", i+'A');
if(j == -) printf("heavy.\n");
else printf("light.\n");
} return ;
}

POJ1207 The 3n + 1 problem

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath> using namespace std; const int maxn = +; int hash[maxn]; int get(int n) {
if(!hash[n]) {
int t = n;
int cnt = ;
while(true) {
cnt++;
if(n == ) return (hash[t] = cnt);
if(n % == ) n = *n+;
else n = n/;
}
}
else return hash[n];
} int main() {
int a, b, n, m; memset(hash, , sizeof(hash)); while(scanf("%d %d", &n, &m) == ) {
a = n, b = m;
if(a > b) swap(a, b);
int max_v = -;
for(int i=a; i<=b; i++) {
if(max_v < get(i)) {
max_v = get(i);
}
} printf("%d %d %d\n", n, m, max_v);
} return ;
}

POJ2105 IP Address

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath> using namespace std; const int maxn = ; char s[maxn]; int main() {
int n;
scanf("%d", &n); while(n--) {
scanf("%s", s); for(int i=; i<; i++) {
int ans = ;
for(int j=; j<; j++) {
ans += (s[i*+j]-'')*(<<(-j));
}
if(i == ) printf("%d", ans);
else printf(".%d", ans);
}
putchar('\n');
} return ;
}

POJ2499 Binary Tree

分析:

用减的话会超时的。用除省时间。

#include <iostream>
#include <cstdio> using namespace std; int main(){
int n, a, b;
int cnt1, cnt2;
scanf("%d", &n);
for(int kase=; kase<=n; kase++) {
cnt1 = cnt2 = ;
scanf("%d%d", &a, &b); while(a != b) {
if(a > b) {
cnt1 += a/b;
a %= b;
if(a == ) {
cnt1--; break;
}
}
else {
cnt2 += b/a;
b %= a;
if(b == ) {
cnt2--; break;
}
}
} printf("Scenario #%d:\n", kase);
printf("%d %d\n\n", cnt1, cnt2);
}
return ;
}

POJ1008 1013 1207 2105 2499(全部水题)的更多相关文章

  1. poj 2105 IP Address(水题)

    一.Description Suppose you are reading byte streams from any device, representing IP addresses. Your ...

  2. 【转】POJ百道水题列表

    以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...

  3. 【BZOJ】初级水题列表——献给那些想要进军BZOJ的OIers(自用,怕荒废了最后的六月考试月,刷刷水题,水水更健康)

    BZOJ初级水题列表——献给那些想要进军BZOJ的OIers 代码长度解释一切! 注:以下代码描述均为C++ RunID User Problem Result Memory Time Code_Le ...

  4. POJ 水题(刷题)进阶

    转载请注明出处:優YoU http://blog.csdn.net/lyy289065406/article/details/6642573 部分解题报告添加新内容,除了原有的"大致题意&q ...

  5. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  6. ACM :漫漫上学路 -DP -水题

    CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit ...

  7. ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)

    1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 154  Solved: 112[ ...

  8. [poj2247] Humble Numbers (DP水题)

    DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...

  9. gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,

    1195: 相信我这是水题 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 821  Solved: 219 Description GDUT中有个风云人 ...

随机推荐

  1. Oracle MERGE INTO的使用方法

    非常多时候我们会出现例如以下情境,假设一条数据在表中已经存在,对其做update,假设不存在,将新的数据插入.假设不使用Oracle提供的merge语法的话,可能先要上数据库select查询一下看是否 ...

  2. [PWA] 9. Service worker registerion && service work's props, methods and listeners

    In some rare cases, you need to ask user to refresh the browsser to update the version. Maybe becaus ...

  3. [转] Nginx + CGI/FastCGI + C/Cpp

    接着上篇<Nginx安装与使用>,本篇介绍CGI/FASTCGI的原理.及如何使用C/C++编写简单的CGI/FastCGI,最后将CGI/FASTCGI部署到nginx.内容大纲如下: ...

  4. 案例:利用累加器计算前N个学生的总成绩和平均成绩

    /* *录入N个学生的成绩,并求出这些学生的总成绩和平均成绩! * */ import java.util.Scanner; public class SumTest{ public static v ...

  5. android 用代码画虚线边框背景(转)

    1.虚线画效果,可以使用Android中的xml来做. 2.直接上代码: <RelativeLayout android:id="@+id/coupon_popup" and ...

  6. ie下面兼容性问题的一些总结

    最后一次搞ie兼容性问题,以后都可以不管了0.0 1.浮动兼容性 1.1IE6下的双边距BUG 在IE6下,块元素有浮动和横向margin的时候,最边上元素的横向margin值会被放大成两倍 解决办法 ...

  7. YII框架开发一个项目的通用目录结构

    YII框架开发一个项目的通用目录结构: 3 testdrive/ 4 index.php Web 应用入口脚本文件 5 assets/ 包含公开的资源文件 6 css/ 包含 CSS 文件 7 ima ...

  8. c# 使用递归 循环遍历导航树结构 并解析

    1.数据书库结构 1 家用电器 0 一级菜单 2 手机.数码.京东通信 0 一级菜单 3 电脑.办公 0 一级菜单 4 家具.家居.厨房 0 一级菜单 5 男装.女装.童装.内衣 0 一级菜单 6 个 ...

  9. 【转】NSString / NSData / char* 类型之间的转换

    原文 :http://www.cnblogs.com/pengyingh/articles/2341880.html NSString 转换成NSData 对象 NSData* xmlData = [ ...

  10. linux术语解析(持续更新)

    1.linux内核有个版本,分别是 longterm: 提供长期支持的内核版本 stable: 稳定版本 Beta 测试版