摘要: 题目: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) 编辑
摘要: 题目:1396Large Caclulating Work思路:题目意思很绕,但是化简之后发现其实就是求n个数的最大公约数#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);}int main(){ int t; int cas=0; while(scanf("%d",&t),t) { int n,an... 阅读全文
posted @ 2013-07-16 13:18 over_flow 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 题目:1563Prime Numbers思路:素数打表+记录#include #include #include #include #include using namespace std;const int maxn =1000000 +10;bool vis[maxn];int dp[maxn];int main(){ memset(vis,true,sizeof(vis)); vis[0]=vis[1]=0; for(int i=2;i*i<maxn;i++) { if(vis[i]) for(int j=2*i;j<maxn;... 阅读全文
posted @ 2013-07-16 00:00 over_flow 阅读(192) 评论(0) 推荐(0) 编辑