codeforces 547A Mike and Frog】的更多相关文章

近期都是这样的题呢. . .... 哎 開始想纯暴力(体如今跳出循环t>=那里.,,,)..,.随着数据变大.. ...(t=499981500166是能够的),,,..,,23333333 超时代码: #include <iostream> #include<bits/stdc++.h> using namespace std; int main() {     long long int mod;     scanf("%lld",&mod);…
 A. Mike and Frog Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/547/problem/A Description Mike has a frog and a flower. His frog is named Xaniar and his flower is named Abol. Initially(at time 0), height of Xaniar is h1…
题目传送门 /* 数论/暴力:找出第一次到a1,a2的次数,再找到完整周期p1,p2,然后以2*m为范围 t1,t2为各自起点开始“赛跑”,谁落后谁加一个周期,等到t1 == t2结束 详细解释:http://blog.csdn.net/u014357885/article/details/46044287 */ #include <cstdio> #include <algorithm> #include <cstring> #include <iostream…
C. Mike and Frog time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mike has a frog and a flower. His frog is named Xaniar and his flower is named Abol. Initially(at time 0), height of Xaniar…
hdu4135 求[L,R]范围内与N互质的数的个数. 分别求[1,L]和[1,R]和n互质的个数,求差. 利用容斥原理求解. 二进制枚举每一种质数的组合,奇加偶减. #include <bits/stdc++.h> using namespace std; typedef long long ll; ; int fac[N], cnt; void factor(int n) { cnt = ; int limit = sqrt(n); ; i <= limit; ++i) { ) fa…
codeforces 547E Mike and Friends 题意 题解 代码 #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back #define rep(i, a, b) for(int i=(a); i<(b); i++) #define per(i, a, b) for(int i=(b)…
codeforces 689 Mike and Shortcuts(最短路) 原题 任意两点的距离是序号差,那么相邻点之间建边即可,同时加上题目提供的边 跑一遍dijkstra可得1点到每个点的最短路,时间复杂度是O(mlogm) #include <cstdio> #include <iostream> #include <cstring> #include <queue> #include <vector> using namespace s…
挺简单的题目,但是有一堆恶心的边界 在刨去恶心的边界之后: 假定我们知道两边的循环节为b1,b2 其中h第一次到达目标的时间为a1,a2 又知道对于答案t t=a1+b1*t1=a2+b2*t2 不妨枚举t1,判断是否存在可行解即可 又因为LCM(b1,b2)就开始循环了 且b1*b2<=b1*mod 所以我们枚举t1的范围在[0,mod]即可 如果在这个范围内无解,则一定无解 #include<cstdio> #include<cstdlib> #include<cs…
传送门 B. Mike and Fun time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike and some bears are playing a game just for fun. Mike is the judge. All bears except Mike are standing in an n × m g…
Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive integers A = [a1, a2, ..., an] and B = [b1, …