Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In order for him to survive, he decided to create one of the first ciphers. This cipher was so incredibly sound, that no one coul…
题目链接:http://poj.org/problem?id=1298 题目大意:按照所给的顺序要求将输入的字符串进行排列. #include <iostream> #include <cstdio> #include <cstring> using namespace std; int main () { ]= {"VWXYZABCDEFGHIJKLMNOPQRSTU"}; ]; ) { gets(ch); )//strcmp是字符的一个函数,也就…
题目链接:http://poj.org/problem?id=1298 思路分析:水题,字符偏移求解,注意字符串输入问题即可. 代码如下: #include <iostream> #include <string> using namespace std; + ; char A[MAX_N]; int main() { int Len; ]; while ( scanf( "%s", Tmp )!= EOF ) { ) break; getchar( ); ge…
The Hardest Problem Ever Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24039   Accepted: 13143 Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In orde…
The Hardest Problem Ever 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1048 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 31307    Accepted Submission(s): 14491 Problem Description Julius Caesa…
The Hardest Problem Ever Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 13035    Accepted Submission(s): 5905 Problem Description Julius Caesar lived in a time of danger and intrigue. The harde…
The Hardest Problem Ever Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 13590    Accepted Submission(s): 6212 Problem Description Julius Caesar lived in a time of danger and intrigue. The hard…
The Hardest Problem Ever Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In order for…
POJ.3468 A Simple Problem with Integers(线段树 区间更新 区间查询) 题意分析 注意一下懒惰标记,数据部分和更新时的数字都要是long long ,别的没什么大坑. 代码总览 #include <cstdio> #include <cstring> #include <algorithm> #define nmax 200000 using namespace std; struct Tree{ int l,r; long lon…
The Hardest Problem Ever Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24241   Accepted: 13227 Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In orde…
POJ 3468.A Simple Problem with Integers 这个题就是成段的增减以及区间查询求和操作. 代码: #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<cstdlib> #include<algorithm> #include<queue> #include<map> usi…
题目:id=3468" target="_blank">poj 3468 A Simple Problem with Integers 题意:给出n个数.两种操作 1:l -- r 上的全部值加一个值val 2:求l---r 区间上的和 分析:线段树成段更新,成段求和 树中的每一个点设两个变量sum 和 num ,分别保存区间 l--r 的和 和l---r 每一个值要加的值 对于更新操作:对于要更新到的区间上面的区间,直接进行操作 加上 (r - l +1)* val…
题目传送门 /* 线段树-成段更新:裸题,成段增减,区间求和 注意:开long long:) */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <cmath> using namespace std; #define lson l, mid, rt << 1 #define rson mid + 1, r,…
题目链接:POJ 1152 An Easy Problem! 题意:求一个N进制的数R.保证R能被(N-1)整除时最小的N. 第一反应是暴力.N的大小0到62.发现当中将N进制话成10进制时,数据会溢出. 这里有个整除,即(N-1)取模为0. 样例:a1a2a3表示一个N进制的数R.化成10进制: (a1*N*N+a2*N+a3)%(N-1)==((a1*N*N)%(N-1)+(a2*N)%(N-1)+(a3)%(N-1))%(N-1)==(a1+a2+a3)%(N-1). 这样防止了数据的溢出…
POJ 2826 An Easy Problem?! -- 思路来自kuangbin博客 下面三种情况比较特殊,特别是第三种 G++怎么交都是WA,同样的代码C++A了 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; const double eps = 1e-8;…
链接:http://poj.org/problem?id=1298&lang=default&change=true 简单的入门题目也有这么强悍的技巧啊!! 书上面的代码: 很厉害有没有=_= n;main(k){,&n,);k-=n<)k%||putchar(n%<?n:n%%+);} 72字节. 用到了read这个函数 对于不需要处理的字符串,没有作处理,简化了很多.…
题目:http://poj.org/problem?id=1298 好吧,给了题目也看不懂……给出翻译(题目名翻译是:最难的问题,233333) 这一看就是老师给出题解: 然而没有什么用哈 最快的办法是,把下面的密文直接拷过来,建个字符数组 然后读入,判断是否是 ENDOFINPUT 不是就读入原文,把大写字母翻译出来 记得换行 最后读掉 END #include<cstdio> #include<cstdlib> #include<cstring> #include&…
一.Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In order for him to survive, he decided to create one of the first ciphers. This cipher was so incredibly sound, th…
A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 58269   Accepted: 17753 Case Time Limit: 2000MS Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of…
A Simple Problem with Integers Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the sum of…
An Easy Problem?! Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7837   Accepted: 1145 Description It's raining outside. Farmer Johnson's bull Ben wants some rain to water his flowers. Ben nails two wooden boards on the wall of his barn…
题目链接:http://poj.org/problem?id=3468 题意:给出一个数列,两种操作:(1)将区间[L,R]的数字统一加上某个值:(2)查询区间[L,R]的数字之和. 思路:数列A,那么区间[1,x]的和为: struct BIT { i64 a[N]; void clear() { clr(a,0); } void add(int x,int t) { while(x<N) a[x]+=t,x+=x&-x; } i64 get(int x) { i64 ans=0; whi…
题目链接:http://poj.org/problem?id=3468 题意就是给你一组数据,成段累加,成段查询. 很久之前做的,复习了一下成段更新,就是在单点更新基础上多了一个懒惰标记变量.updata的时候刚好在(l==T[p].l && r==T[p].r)的时候不更新下去,暂时用一个懒惰变量存了起来(所以才懒惰),不然继续更新下去复杂度会很高.在query的时候更新到下一层(看代码,多打打就有体会了). #include <iostream> #include <…
1.链接地址: http://bailian.openjudge.cn/practice/1658 http://poj.org/problem?id=1658 2.题目: 总时间限制: 1000ms 内存限制: 65536kB 描述 Eva的家庭作业里有很多数列填空练习.填空练习的要求是:已知数列的前四项,填出第五项.因为已经知道这些数列只可能是等差或等比数列,她决定写一个程序来完成这些练习. 输入 第一行是数列的数目t(0 <= t <= 20).以下每行均包含四个整数,表示数列的前四项.…
1.链接地址: http://bailian.openjudge.cn/practice/2813 http://poj.org/problem?id=1681 2.题目: 总时间限制: 1000ms 内存限制: 65536kB 描述 有一个正方形的墙,由N*N个正方形的砖组成,其中一些砖是白色的,另外一些砖是黄色的.Bob是个画家,想把全部的砖都涂成黄色.但他的画 笔不好使.当他用画笔涂画第(i, j)个位置的砖时, 位置(i-1, j). (i+1, j). (i, j-1). (i, j+…
Painter's Problem 题意:给一个n*n(1 <= n <= 15)具有初始颜色(颜色只有yellow&white两种,即01矩阵)的square染色,每次对一个方格染成黄色时,同时会把周围的方格也染成黄色.(这和1222的开关一样的关联关系)问最后可以将square全部染成黄色的最小染色方格数? 思路: 1.直接预处理出增广矩阵,和1222不同的是里面有最优解的条件,贪心的思想是把自由变元看成是没染色的,但是其他非自由变元(除去自由维度之外的变量)是可以通过自由变元的取…
Problem Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In order for him to survive, he decided to create one of the first ciphers. This cipher was so incredibly sou…
A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 59046   Accepted: 17974 Case Time Limit: 2000MS Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of…
A Simple Problem with Integers   Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the sum o…
An Easy Problem   Description As we known, data stored in the computers is in binary form. The problem we discuss now is about the positive integers and its binary form. Given a positive integer I, you task is to find out an integer J, which is the m…