Submission #1845521
Source Code Expand
#include <iostream> #include <string> #include <vector> #include <deque> #include <algorithm> #include <cstdio> using namespace std; long long int gcd(long long int a, long long int b) { return b == 0 ? a : gcd(b, a % b); } long long int a, b; long long int dfs(long long int ret, bool can, vector<long long int> picked, long long int x) { //cerr << "(" << ret << "," << can << ",[" << picked.size() << "]," << x << ") "; if (can) { picked.push_back(x); ++ret; } //cerr << x << " ----" << endl; //for (auto&& X : picked) cerr << X << " "; //cerr << endl; for (long long int next = x + 1; next <= b; ++next) { //cerr << "--------------- " << next << endl; bool f = true; for (long long int n : picked) { if (gcd(n, next) > 1) { //cerr << "dropped " << next << endl; ret = dfs(ret, false, vector<long long int>(picked), next); f = false; break; } } if (f) { //cerr << "picked " << next << endl; ret = dfs(ret, true, vector<long long int>(picked), next); } } //cerr << endl; return ret; } int main() { cin >> a >> b; long long int ans = 1; for (long long int i = a; i <= b; ++i) { //cerr << i << " ============" << endl; ans += dfs(0, true, vector<long long int>(), i); } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - すぬけそだて――ごはん―― |
User | nahcnuj |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1543 Byte |
Status | WA |
Exec Time | 2103 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, s1.txt, s2.txt, s3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 1 ms | 256 KB |
02.txt | WA | 1 ms | 256 KB |
03.txt | TLE | 2103 ms | 256 KB |
04.txt | TLE | 2103 ms | 256 KB |
05.txt | TLE | 2103 ms | 256 KB |
06.txt | TLE | 2103 ms | 256 KB |
07.txt | AC | 1 ms | 256 KB |
08.txt | WA | 232 ms | 256 KB |
09.txt | TLE | 2103 ms | 256 KB |
10.txt | TLE | 2103 ms | 256 KB |
11.txt | TLE | 2103 ms | 256 KB |
12.txt | TLE | 2103 ms | 256 KB |
13.txt | TLE | 2103 ms | 256 KB |
14.txt | TLE | 2103 ms | 256 KB |
15.txt | TLE | 2103 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |
s3.txt | TLE | 2103 ms | 256 KB |