上一页 1 2 3 4 5 6 7 ··· 9 下一页
摘要: 题目:Jolly Jumpers思路:标记一下就ok#include #include #include #include #include using namespace std;bool vis[3010];int main(){ int n; bool tag; while(cin>>n) { for(int i=1;i>x0; int tmp=n; tmp--; while(tmp--) { cin>>x; if(abs(x-x0)<3001) ... 阅读全文
posted @ 2013-07-18 09:36 over_flow 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=2685思路:gcd(A^m-B^m,A^n-B^n)= A^gcd(m,n) - B^gcd(m,n) 这里特殊情况B=1#include #include #include #include #include using namespace std;long long gcd(long long a,long long b){ if(b==0) return a; return gcd(b,a%b);}long long Pow(long long a,long long b... 阅读全文
posted @ 2013-07-17 17:18 over_flow 阅读(248) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=2891思路:扩展欧几里得#include #include #include #include #include using namespace std;#define maxn 100010int n;long long a[maxn],b[maxn];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 ... 阅读全文
posted @ 2013-07-17 16:31 over_flow 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.nefu.edu.cn/test/problemshow.php?problem_id=507思路:呵呵 三层一层一层迭代求出循环节。#include #include #include #include #include using namespace std;// 1e9+7// 222222224// 183120int main(){ long long a=0,b=1; long long mod=222222224; long long ans=1; long long c=(3*b+a)%mod; a=b; b=c;... 阅读全文
posted @ 2013-07-17 16:14 over_flow 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 题目:No more tricks, Mr Nanguo思路:佩尔方程,剩下的递归用矩阵快速幂做#include #include #include #include #include using namespace std;#define mod 8191struct Matrix{ int m[3][3];}D,E;void init(){ for(int i=1;i>n>>k) { if(is_sqr(n)) cout<<"No answers can meet such conditions"<<endl; else ... 阅读全文
posted @ 2013-07-16 16:33 over_flow 阅读(306) 评论(0) 推荐(0) 编辑
摘要: 题目:Biorhythms思路: 扩展欧几里得#include #include #include #include #include #include #include using namespace std;int w[4]={0,23,28,33},a[4];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 ans=ex... 阅读全文
posted @ 2013-07-16 15:49 over_flow 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.nefu.edu.cn/test/problemshow.php?problem_id=66思路:直接对10取余,剩下的化简就可以到用科学技术法表示的该数的首位#include #include #include #include #include using namespace std;int main(){ int t; scanf("%d",&t); while(t--) { long long n; scanf("%lld",&n); int ans=(int)pow(10,n*log10(n... 阅读全文
posted @ 2013-07-16 15:21 over_flow 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 题目:Raising Modulo Numbers思路:快速幂#include #include #include #include #include using namespace std;unsigned long long Pow(unsigned long long a,unsigned long long b,unsigned long long mod){ unsigned long long ans=1; while(b) { if(b&1) { b--; ans=(ans*a)%mod; ... 阅读全文
posted @ 2013-07-16 14:47 over_flow 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 题目:滑雪思路:dp#include #include #include #include #include using namespace std;#define maxn 110int vis[maxn][maxn];int num[maxn][maxn];int r,c;int move[4][2]={0,1,0,-1,1,0,-1,0};int dfs(int x,int y){ if(vis[x][y]) return vis[x][y]; int ans=0; for(int i=0;i=1&&yy>=1&xxnum[xx][yy]) ... 阅读全文
posted @ 2013-07-16 14:12 over_flow 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 题目:1782.The jackpot思路:最大字段和#include #include #include #include #include using namespace std;#define maxn 10010int dp[maxn],num[maxn];int main(){ int n; while(scanf("%d",&n),n) { int mx=0; memset(dp,0,sizeof(dp)); for(int i=1;i0) dp[i]=num[i]+dp[i-1]; ... 阅读全文
posted @ 2013-07-16 13:44 over_flow 阅读(177) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 9 下一页