1 solutions
-
0
纯模拟,甚至用std::cin都不会超时
#include <cstdio> #include <algorithm> #include <cmath> int f[2000010], n; int main() for(int i = 0; i <= 2000000; i = i + 1) { f[i] = -1; }//初始化 std::cin >> n; for(int i = 1; i <= n; i ++) { double a, t; std::cin >> a >> t; for(double i = 1; i <= t; i = i + 1) { f[int(a * i)] = f[int(a * i)] * -1;//每一个满足条件的灯改变状态 } for(int i = 1; i <= 2000000; i ++) { if(f[i] == 1) { std::cout << i; return 0;//找到就结束,不用再找了 } } return 0; }
- 1
Information
- ID
- 161
- Time
- 1000ms
- Memory
- 125MiB
- Difficulty
- 1
- Tags
- # Submissions
- 4
- Accepted
- 2
- Uploaded By