随笔分类 -  acm easy

zoj 2971 Give Me the Number
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2971 开始想用map的键值对来做,想想发现没必要,直接模拟就可以了。用一个数组打出0—20和30,40..90等数的英文,输入时进行匹配,匹配成功便通过它们与下标之间的关系确定。输入为million,hundred,thousand时,当前值要乘相应10^n。 用三个数n1, n2, n3分别记录每三位数,最后相加即可。code:#include<cstdio>#include<cstring>usingnamespacestd;charstr[ 阅读全文
posted @ 2012-04-28 22:03 追逐. 阅读(453) 评论(0) 推荐(1)
zoj 2058 The Archaeologist's Trouble II
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2058 一道简单的找规律题。 每一行中的两个相邻字符必定不同。 行从1开始,偶数行的'@'和'*'必定各占一半,奇数行分两种情况,若不全为'?',此行中第一个不为'?'的字符及其下标的奇偶决定'@'个数,若为'@'且下标为奇则'@'为i/2+1,反则为i/2。code:#include<cstdio>#include<iostream># 阅读全文
posted @ 2012-04-11 23:19 追逐. 阅读(227) 评论(0) 推荐(0)
poj 3273
摘要:简单二分,下限为每天花费的最大值,上限是所有天数花费的总和.#include<iostream>#include<cstdio>usingnamespacestd;intmon[100005];inti,j,n,m;intjud(intmid){ints=0,count=1;for(i=0;i<n;i++){s+=mon[i];if(s>mid){s=mon[i];count++;}}if(count>m)returntrue;elsereturnfalse;}intmain(){intans;intmax,sum;while(scanf(" 阅读全文
posted @ 2011-10-21 17:07 追逐. 阅读(267) 评论(0) 推荐(0)
hdu 2141(二分)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2141#include<iostream>#include<algorithm>#include<cstdio>usingnamespacestd;inta[505],b[505],c[505],s[1005],ans[250005];intmain(){intl,n,m,x,mid,low,high,i,j,t=1;boolflag;while(scanf("%d%d%d",&l,&n,&m)!=EOF){for(i= 阅读全文
posted @ 2011-10-12 23:46 追逐. 阅读(226) 评论(0) 推荐(0)
hdu 1873
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1873 主要是排序,sort和qsort是不稳定排序,所以在此题种不可用。而stable_sort为稳定排序,每次IN后对vector排序即可。#include<iostream>#include<vector>#include<algorithm>usingnamespacestd;structpain{inttip,id;};intcmp(paina,painb){returna.tip>b.tip;}intmain(){intn;typedefvect 阅读全文
posted @ 2011-10-10 12:16 追逐. 阅读(268) 评论(0) 推荐(0)
poj 1028 (STL)
摘要:题目链接: http://poj.org/problem?id=1028 4、5个月前就做这题了,当时是用数组模拟的,结果RE到吐血!这次直接用STL模板,一次AC!文盲的悲哀啊!#include<iostream>#include<fstream>#include<string>#include<stack>usingnamespacestd;intmain(){stack<string>a;stack<string>b;//b记录BACK操作前的页面stringc;a.push("http://www.acm 阅读全文
posted @ 2011-09-19 22:29 追逐. 阅读(453) 评论(0) 推荐(0)
poj 1250
摘要:本来用cin cout输入输出,可不知道怎么弄得cin was not declared in this scorpe,怎么调都不行,郁闷...#include<iostream>#include<cstdio>#include<cstring>intmain(){intn,d;chara[100];boolv[100],e[100];while(scanf("%d",&n)!=EOF&&n){scanf("%s",&a);intb=0;memset(v,0,sizeof(v));mem 阅读全文
posted @ 2011-09-14 02:19 追逐. 阅读(238) 评论(0) 推荐(0)
poj 3299 Humidex
摘要:题目链接:http://poj.org/problem?id=3299 挺扯蛋的一题,本来想刷点水题,结果让这题的题目给虐了...抽空得好好补补英语了。主要是公式的推导代码:#include<iostream>#include<cstdio>#include<math.h>usingnamespacestd;floate=2.718281828;floatfun1(floath,floatd){returnh-(0.5555*((6.11*pow(e,5417.7530*(1/273.16-1/(d+273.16))))-10.0));}floatfun2( 阅读全文
posted @ 2011-09-02 20:25 追逐. 阅读(220) 评论(0) 推荐(0)
USACO 1.2.1 Milking Cows
摘要:题意: 给定N个挤奶工取奶的起始时间和结束时间,求其中至少一个在取奶的最长时间和都没在取奶的最长时间。起止时间为5:00后以秒为单位的时间点,一个挤奶工对应一头奶牛。 又一道让BUG给挂掉的题,这次还更无语。input4100 200201 301302 402403 503output100 1 我运行的确实是"100 1"啊,可那测评系统非说我运行的是"100 0",无奈... > Run 2: Execution error: Your program did not produce an answer that was judged as 阅读全文
posted @ 2011-08-26 15:57 追逐. 阅读(278) 评论(0) 推荐(0)
HDU 2293
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2293 啥也不说了,一个简单的模拟让我弄成这样。 注意两个地方: 1. 最后不能用时间递增来模拟过程,要先求出每人hp<=0的时间,通过对比时间来决定胜负,否则会超时。 2. 过程中的取模要放到循环中,每次的相乘都取模,否则会乘法溢出。代码:#include<iostream>#include<cstdio>#include<cstring>usingnamespacestd;intmain(){intn;cin>>n;inthp1,hp2,st1,st2 阅读全文
posted @ 2011-08-25 10:28 追逐. 阅读(282) 评论(0) 推荐(0)
poj 2218
摘要:题意: N个人减肥,给出他们的起始体重和减肥的天数,而且每天能减去一磅的体重。要求按减肥者减肥过后的体重降序排列姓名。 输入:姓名 减肥天数 起始体重 输出:降序输出姓名 此题原想用C++写,但因不太了解C++字符串操作的基本方法(strcmp()),无法实现部分功能,所以改用JAVA。创建一个类存放减肥者的信息(姓名,减肥后的体重),根据计算得出的weight对对象数组排序。要注意要求每组数据输出后保留一行空格。 代码: import java.util.* ; class People{ String name ;int weigth ;} public class Main{ publi 阅读全文
posted @ 2011-08-14 12:19 追逐. 阅读(304) 评论(0) 推荐(0)
poj 1666
摘要:DescriptionThere is a huge mountain outside Kicc's house, and Kicc has to climb the mountain every time he wants to go out. It costs him a lot of time and he wants to change the situation. Yes, he figures out a good idea - to move the mountain away! But there is a problem. There are some wild an 阅读全文
posted @ 2011-08-14 12:17 追逐. 阅读(338) 评论(0) 推荐(0)