06 2013 档案

摘要:题目:Big Chocolate思路:很久之前写过,用递归一次一次的拆分的,写复杂了,直接输出m*n-1即可,证明自己想#include #include #include #include #include using namespace std;int main(){ long long m,n; while(scanf("%lld%lld",&m,&n)!=EOF) { cout<<m*n-1<<endl; } return 0;}View Code 阅读全文
posted @ 2013-06-23 10:07 over_flow 阅读(124) 评论(0) 推荐(0)
摘要:题目:Quotient Polynomial思路:水题,就是感觉对输入有点措手不及,捡起来以前大一的时候用的读取到回车退出了。然后就是多项式分解。#include #include #include #include #include #include using namespace std;vectorv;int main(){ int k; char s; while(scanf("%d%*c",&k)!=EOF) { v.clear(); int tag=1,num=0; while(scanf("%c",&s)!=EOF... 阅读全文
posted @ 2013-06-23 10:07 over_flow 阅读(149) 评论(0) 推荐(0)
摘要:题目:Box of Bricks思路:水题。。。这个和挑战编程上那题一样,求最小移动啥啥的,所以只需要判断比均值大的和比均值小的部分,求最大值即可#include #include #include #include #include using namespace std;int num[55];int main(){ int n; int t=0; while(scanf("%d",&n),n) { int sum=0; for(int i=1;isum) tmp+=num[i]-sum; ... 阅读全文
posted @ 2013-06-23 10:03 over_flow 阅读(131) 评论(0) 推荐(0)
摘要:题目:The ? 1 ? 2 ? ... ? n = k problem思路:这个跟喵呜上次出的题一样,因为求的值化简一下就是sum(1...n)-2*subsum(1..n)=k,那么我们就只要保证(sum(1...n)-k)%2==0就行了,因为那个subsum是可以遍历1 to sum(1..n)的数的,同时要保证它大于0== 我直接交上次写的代码,结果WA了,原因在于多少还是有个trick的,output里有说n是大于等于1的,那么当k=0时,我的程序跑出来答案是0,很明显这个应该特判,答案是3(1+2-3)。#include #include #include #include #i 阅读全文
posted @ 2013-06-23 10:01 over_flow 阅读(159) 评论(0) 推荐(0)
摘要:题目:Secret Research思路:水题。。也是直接判断一下#include #include #include #include #include using namespace std;bool positive(string s){ if(s=="1"||s=="4"||s=="78") return true; return false;}bool negative(string s){ int l=s.size(); if(s[l-1]=='5'&&s[l-2]=='3' 阅读全文
posted @ 2013-06-23 09:55 over_flow 阅读(146) 评论(0) 推荐(0)
摘要:题目:Cube painting思路:水题。。。直接判断一下就是了#include #include #include #include #include using namespace std;int main(){ string a,b; while(cin>>a) { b=""; int i; for(i=6;i<=11;i++) b+=a[i]; int ans=0; for(i=0;i<3;i++) { if((a[0]==b[i]&&a[... 阅读全文
posted @ 2013-06-23 09:54 over_flow 阅读(185) 评论(0) 推荐(0)
摘要:题目:Ant on a Chessboard思路:直接暴力吧,大水#include #include #include #include #include using namespace std;int main(){ int n; while(scanf("%d",&n)!=EOF,n) { int cnt=0; long long sum=0; while(sumcnt) { now-=cnt; printf("%d %d\n",cnt-now,cn... 阅读全文
posted @ 2013-06-23 09:53 over_flow 阅读(165) 评论(0) 推荐(0)
摘要:题目:Power of Cryptography思路:水。。直接输出。。记住double比你想象中大得多#include #include #include #include #include using namespace std;int main(){ double n,p; while(scanf("%lf%lf",&n,&p)!=EOF) { printf("%.lf\n",pow(p,1.0/n)+1e-6); } return 0;}View Code 阅读全文
posted @ 2013-06-23 09:51 over_flow 阅读(125) 评论(0) 推荐(0)
摘要:题目:Repackaging好吧,这题我不会,第一反应是构造了一个多元不定方程,然后想到了之前做过的一个稍微有一点类似的题【USACO3.2.4】Feed Ratios饲料调配(这个题我是看大仙博客刷的,是道枚举类型的高斯函数裸题),可是对于这个题来说应该就无效了。google搜到的结题报告对应的是uva 10089,看了看别人的思路,发现尼玛,竟然没当成数学题做,==。大牛们的思路: 判断点(1,1,1)是否在题目给定的向量的棱锥内 ; 另外一种思路是判断二维平面内点是否在凸包内的问题。。。。唉,不会唉,膜拜大神吧: UVa Problem 10089 Repackaging 阅读全文
posted @ 2013-06-22 07:27 over_flow 阅读(138) 评论(0) 推荐(0)
摘要:题目:Marbles思路: 扩展欧几里得。 由于公式套出来的答案x,y,如果是(x*c)%b的话,求的是满足条件的x最接近于0的那组解,所以根据两种box的单位运输价值来判断到底是取x越小越好还是取y越小越好#include <cstdio>#include <algorithm>#include <iostream>#include <cmath>using namespace std;long long one,two,tag;long long c1,c2,n1,n2,n;void one_first(){ one=n/n1,two=0; 阅读全文
posted @ 2013-06-21 21:16 over_flow 阅读(204) 评论(0) 推荐(0)
摘要:题目:Smith Numbers思路: 从当前数字开始往上暴力,找到合数之后质因式分解,看是否满足那个关系。#include <iostream>#include <cstring>#include <cmath>#include <algorithm>#include <cstdio>using namespace std;#define maxn 40000bool vis[maxn];int n_prime=0;int prime[maxn/8];int cnt[maxn/8];void Prime(){ memset(vis, 阅读全文
posted @ 2013-06-21 20:04 over_flow 阅读(202) 评论(0) 推荐(0)
摘要:题目:Summation of Four Primes思路:好像有个什么定理说是任意的一个偶数都可以表示成两个素数的和,所以对于输入的n,最糟糕的情况是n=8=2+2+2+2,小于8的无解,对于大于8的情况,如果是奇数,我们就拿一个2和一个3出来,如果是偶数,我们就拿两个2出来,那么剩下的就是求某个偶数等于两个素数之和,继续暴力#include <cstdio>#include <algorithm>#include <cstring>#include <cmath>#include <iostream>using namespace 阅读全文
posted @ 2013-06-21 14:21 over_flow 阅读(220) 评论(0) 推荐(0)
摘要:题目:Factovisors思路:直接质因式分解除数,然后求得阶乘各质因子的幂是否大于除数的,注意特判情况(存在一个较大的素数,这个要判断n是不是大于等于那个很大的素数)#include <cstdio>#include <iostream>#include <cstring>#include <cmath>#include <algorithm>using namespace std;#define maxn 60000bool vis[maxn];int prime[maxn];int cnt[maxn];int n_prime= 阅读全文
posted @ 2013-06-21 14:03 over_flow 阅读(174) 评论(0) 推荐(0)
摘要:题目:Euclid Problem思路:裸的扩展欧几里得#include <cstdio>#include <iostream>#include <algorithm>#include <cmath>#include <cstring>using namespace std;long long exgcd(long long a,long long b,long long &x,long long &y){ if(b==0) { x=1; y=0; return a; } else { long long a... 阅读全文
posted @ 2013-06-21 11:40 over_flow 阅读(150) 评论(0) 推荐(0)
摘要:题目:Carmichael Numbers思路:直接判是不是素数然后满不满足费马小定理就行了#include <cstdio>#include <algorithm>#include <cstring>#include <cmath>#include <iostream>using namespace std;#define maxn 66000int vis[maxn];void Prime(){ memset(vis,1,sizeof(vis)); vis[0]=vis[1]=0; for(int i=2;i*i<maxn; 阅读全文
posted @ 2013-06-21 11:25 over_flow 阅读(159) 评论(0) 推荐(0)
摘要:题目:Light, more light思路:之前做过了的,直接判是不是完全平方数就可以知道约数的奇偶性了#include <cstdio>#include <algorithm>#include <cstring>#include <cmath>#include <iostream>using namespace std;int main(){ long long n; while(scanf("%lld",&n),n) { long long tmp=(long long)sqrt(n); if(tmp 阅读全文
posted @ 2013-06-21 11:24 over_flow 阅读(132) 评论(0) 推荐(0)
摘要:题目:Factoring Large Numbers思路:开始一看,感觉暴不了,然后题目中有说大于100w的素因子只有一个,所以那就暴100w以内的质因子就行,最后剩下的不等于1的话,就是一个大于100w的素因子直接输出#include <cstdio>#include <iostream>#include <cmath>#include <algorithm>#include <cstring>using namespace std;#define maxn 1000001bool vis[maxn];int prime[maxn] 阅读全文
posted @ 2013-06-21 10:47 over_flow 阅读(164) 评论(0) 推荐(0)
摘要:题目:How many zero's and how many digits ?思路:求0的,我们先把base分解质因式,然后求num对base各质因式非0的幂的倍数,取最小值。 求位数的,只求取log10,注意一下精度问题#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <iostream>using namespace std;#define maxn 810int vis[maxn];int prime[maxn 阅读全文
posted @ 2013-06-21 09:39 over_flow 阅读(182) 评论(0) 推荐(0)
摘要:题目:Multiplying by Rotation思路:求base进制下,长度最短的数字满足乘以factor,使得原来的最低位等于最高位。#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <iostream>using namespace std;int main(){ int base,first,factor; while(cin>>base>>first>>factor) { int 阅读全文
posted @ 2013-06-21 00:28 over_flow 阅读(126) 评论(0) 推荐(0)
摘要:题目:Pseudo-Random Numbers思路:存在循环节,注意开始一部分不一定是循环的#include <cstdio>#include <iostream>#include <algorithm>#include <cmath>#include <cstring>#include <vector>using namespace std;long long z,i,mod,l;long long num[10000000];long long fun(long long x){ return (z*x+i)%mod 阅读全文
posted @ 2013-06-20 20:31 over_flow 阅读(153) 评论(0) 推荐(0)
摘要:题目:Uniform Generator思路:因为这样的一个循环的取模总会出现循环节,所以只需要判断step和mod是否互质#include <cstdio>#include <iostream>#include <cstring>#include <cmath>#include <algorithm>#include <cstdlib>#include <ctime>using namespace std;int step,mod;int gcd(int a,int b){ if(b==0) return a 阅读全文
posted @ 2013-06-20 19:30 over_flow 阅读(197) 评论(0) 推荐(0)
摘要:题目:Code Refactoring思路:直接暴力。。水题#include <cstdio>#include <iostream>#include <cstring>#include <algorithm>#include <cmath>using namespace std;bool is_ok(int a,int b,int c,int d){ if(a==b||b==c||a==c||a==d||b==d||c==d) return false; return true;}int main(){ int t; scanf(&q 阅读全文
posted @ 2013-06-20 18:53 over_flow 阅读(175) 评论(0) 推荐(0)
摘要:题目:Just the Facts思路:枚举10000素数内,各因子出现的次数,然后取模为10。因为0是由2和5构成的,所以2和5的幂单独讨论,同时由于2的幂肯定大于5的,所以我们最后要算的再乘上2的减去后的幂就可以得到。#include <cstdio>#include <algorithm>#include <cmath>#include <cstring>#include <iostream>using namespace std;const int maxn=10001;int n_prime=0;int prime[maxn 阅读全文
posted @ 2013-06-20 18:42 over_flow 阅读(149) 评论(0) 推荐(0)
摘要:题目:Light, more light思路:第一次做的时候是素数打表,然后分解质因式,求约数个数是不是奇数的,按理来说没错,但是就是过不了。发现的一个陷阱是2^32-1这个值肯定不能用int,还是找不到分解质因数做法的错 ==其实这个只要判断是不是完全平方数就ok了,不解释,自己看#include <cstdio>#include <algorithm>#include <cmath>#include <cstring>#include <iostream>using namespace std;int main(){ long l 阅读全文
posted @ 2013-06-20 15:12 over_flow 阅读(141) 评论(0) 推荐(0)
摘要:题目:Skew Binary思路:水题。。#include <cstring>#include <algorithm>#include <iostream>#include <cmath>#include <cstdio>using namespace std;int main(){ string s; while(cin>>s) { if(s=="0") break; long long ans=0; int x=1; for(int i=s.size()-1;i>=0;i--) {... 阅读全文
posted @ 2013-06-20 14:43 over_flow 阅读(123) 评论(0) 推荐(0)
摘要:题目:跳舞毯思路:递归水题,n-1时,由B,C跳回A的种数是f(n-1),对于n-2的情况就是,选择B,C中一个点,跳过去,然后跳回A,因此种数是2*f(n-2) 所以 f(n)=f(n-1)+2*f(n-2)#include <cstdio>#include <iostream>#include <cstring>#include <algorithm>#include <cmath>using namespace std;int f[1010];int main(){ f[0]=0; f[1]=0; f[2]=2; for(int 阅读全文
posted @ 2013-06-20 14:28 over_flow 阅读(198) 评论(0) 推荐(0)
摘要:题目:Dynamic Programming?思路:直接暴力。。水题#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <iostream>using namespace std;__int64 num[1010];int main(){ int t; scanf("%d",&t); for(int cases=1;cases<=t;cases++) { int n; scanf("% 阅读全文
posted @ 2013-06-20 14:12 over_flow 阅读(166) 评论(0) 推荐(0)
摘要:题目:统计问题思路:将问题转换成,前一状态是左或者右的,或者前的,设左右的那种是A(n-1),前的那种是B(n-1),那么对于当前的状态,如果现在往前B(n)=2*A(n-1)+B(n-1),如果往左:A(n)=A(n-1)+B(n-1) 往右的相同,那么对于这样的一个问题,可以构造矩阵或者求递推式,练下矩阵,所以写成构造矩阵的了#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <iostream>using namespac 阅读全文
posted @ 2013-06-20 10:34 over_flow 阅读(145) 评论(0) 推荐(0)
摘要:题目:67A - Partial Teacher思路:多写几组数据就可以找到规律了,就是要找到当前位置,往左往右的不完全连续L和R的最大长度#include <cstdio>#include <iostream>#include <cstring>#include <cmath>#include <algorithm>#include <queue>using namespace std;queue<int>q;int main(){ while(!q.empty()) q.pop(); int n; stri 阅读全文
posted @ 2013-06-19 20:47 over_flow 阅读(199) 评论(0) 推荐(0)
摘要:题目:10361-Automatic Poetry思路:水题。。暴力#include <cstdio>#include <iostream>#include <cstring>#include <algorithm>#include <cmath>using namespace std;char str[110];string s[6];int main(){ int t; scanf("%d",&t); getchar(); while(t--) { gets(str); for(int i=0;i< 阅读全文
posted @ 2013-06-16 17:28 over_flow 阅读(162) 评论(0) 推荐(0)
摘要:题目:10010-Where's Waldorf?思路:水题。。暴力#include <cstdio>#include <iostream>#include <cstring>#include <algorithm>#include <cmath>using namespace std;int row,col,l;char s[55][55];char str[110];int dir[8][2]={-1,1,0,1,1,1,-1,0,1,0,-1,-1,0,-1,1,-1};bool is_ok(int i,int j,in 阅读全文
posted @ 2013-06-16 16:48 over_flow 阅读(276) 评论(0) 推荐(0)
摘要:题目:401-Palindromes水题#include <cstdio>#include <iostream>#include <algorithm>#include <cmath>#include <cstring>#include <vector>#include <map>using namespace std;map<char,char>m;void init(){ m.clear(); m['3']='E'; m['E']='3&# 阅读全文
posted @ 2013-06-16 14:50 over_flow 阅读(187) 评论(0) 推荐(0)
摘要:Problem HDescription 喵星人和汪星人玩游戏。 这个游戏是这样的,有n个石子排成一排,其中第m个是白色的,其他都是黑色的,喵星人先走,汪星人后走,每步可以颠倒任意连续k个石头的顺序,且这k个石头中必须存在白色石头。谁先将白色石头移动到位置l谁就获胜,假设喵星人和汪星人都是选择最优的走法,问谁将获胜。Input 第一行输入一个数T,表示测试数据个数,对于每组测试数据,输入四个数n,m,k,l(1<n<=10^6,1<=m,k,l<=n),数据保证刚开始时白色石头不在位置l。Output 对于每组测试数据,如果喵星人获胜,输出"Miao" 阅读全文
posted @ 2013-06-14 00:06 over_flow 阅读(197) 评论(0) 推荐(0)
摘要:Problem GDescription 话说蹦蹦跳跳的小兔纸很可爱吧。 假设有一只兔纸在零点,每次会往左或者往右跳,但是这只兔纸跳第i步,它的跳跃距离一定为i,请问该兔纸最少要跳几步才能跳到位置n。Input 第一行输入一个数T,表示测试数据个数,对于每个测试数据,输入一个数n(-10^9<=n<=10^9),表示跳跃的最终位置。Output 对于每组测试数据,输出1个数,表示该兔纸要跳几次才能跳到位置n。Sample Input 2 2 6Sample Output 3 3Hint: 对于第一组测试数据,第一次往右边跳1格,跳到1,第二次往左边跳2格,跳到-1,第三次往... 阅读全文
posted @ 2013-06-13 20:35 over_flow 阅读(133) 评论(0) 推荐(0)
摘要:Problem FDescription话说喵呜没事喜欢玩耗纸玩偶,现在有一个棋盘,有n行m列,喵呜在会在上面摆耗纸玩偶,话说每一个格子最多摆一个,而且他不希望任意两个耗纸玩偶的欧几里得距离为2,问喵呜最多能摆几只耗纸玩偶。假设第一只耗纸的位置在x1,y1,第二只耗纸的位置在x2,y2,那么这两只耗纸的欧几里得距离为Input第一行输入一个数T,表示测试数据个数,对于每个测试数据,输入两个数n,m(0<n,m<10^9)Output对于每个测试数据,输出一个数,表示最多摆几个耗纸玩偶。Sample Input33 23 38 5Sample Output4520Hint下列摆法其中 阅读全文
posted @ 2013-06-13 20:01 over_flow 阅读(171) 评论(0) 推荐(0)
摘要:水题。#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <iostream>using namespace std;int num[110][110];int row,col;char str;int t=0;int main(){ while(scanf("%d%d",&row,&col)!=EOF) { if(row==0&&col==0) break; memset(n 阅读全文
posted @ 2013-06-13 19:38 over_flow 阅读(146) 评论(0) 推荐(0)
摘要:水题。求最小交易总额。#include <cstdio>#include <iostream>#include <algorithm>#include <cmath>#include <cstring>using namespace std;double money[1010];int main(){ int n; while(scanf("%d",&n),n!=0) { double avg=0; for(int i=1;i<=n;i++) { scanf("%lf",& 阅读全文
posted @ 2013-06-13 19:36 over_flow 阅读(141) 评论(0) 推荐(0)

点击右上角即可分享
微信分享提示