Submission #2840698
Source Code Expand
/* for (int i = 0; i < N; ++i){} // 各桁の和を計算する関数 int findSumOfDigits(int n) { int sum = 0; while (n > 0) { // n が 0 になるまで sum += n % 10; n /= 10; } return sum; } sort(a, a + N, greater<int>()); // a[0:N] を大きい順にソート int num[110] = {0}; // バケット for (int i = 0; i < N; ++i) { num[d[i]]++; // d[i] が 1 個増える } map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名 for (int i = 0; i < N; ++i) { auto itr = mp.find(s[i]); // s[i] が設定されているか? if(itr != mp.end() ) { mp[s[i]] += 1; } else { mp[s[i]] += 1 ; } } stack<int> s; //intをデータとするスタックを用意 s.push(1); //{} -> {1} printf("%d\n", s.top()); // 3 s.pop(); queue<int> que; //intをデータとするキューを用意 que.push(1); //{} -> {1} printf("%d\n", que.front()); // 1 que.pop(); */ #include <iostream> #include <set> #include <map> #include <string> #include <math.h> #include <algorithm> #include <vector> #include <stack> #include <queue> #include <bitset> #include <numeric> using namespace std; // #define for(i,a,b) for (int i=(a);i<(b);++i) typedef long long ll; typedef pair<int,int> point; #define rep(i,n) for(i,0,n) bool judge(vector<int> v){ bool ans = true; sort(v.begin(), v.end()); for (int i = 0; i < v.size()-1; ++i) { if (v[i]==v[i+1]) return false; } int sum = 0; for (int x : v) sum += x; for (int i = 0; i < v.size(); ++i) { int ai = v[i]; int sumi = sum - ai; int gcdi = __gcd(ai, sumi); if (gcdi==1) return false; } int gcd_all = __gcd(v[0], v[1]); for (int x : v) gcd_all = __gcd(gcd_all, x); if (gcd_all!=1) ans = false; return ans; } int main() { // 入力 int N; cin >> N; // 解法 vector<int> v = {2, 5, 63}; // vector<int> v = {2, 5, 6}; // vector<int> v = {2, 5}; // bool ans = judge(v); while (v.size()<N){ int i = 20; while (i<=3000){ v.push_back(i*10); if (judge(v)==true) break; else{ v.pop_back(); ++i; } } } //出力 for (int x: v)printf("%d ", x); // if (ans) printf("Yes\n"); // else printf("No\n"); }
Submission Info
Submission Time | |
---|---|
Task | B - GCD Sequence |
User | osciiart |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2315 Byte |
Status | TLE |
Exec Time | 2103 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 600 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.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, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, s1.txt, s2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | TLE | 2103 ms | 256 KB |
02.txt | AC | 1 ms | 256 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 1 ms | 256 KB |
06.txt | AC | 1 ms | 256 KB |
07.txt | AC | 1 ms | 256 KB |
08.txt | AC | 1 ms | 256 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | AC | 1 ms | 256 KB |
11.txt | AC | 1 ms | 256 KB |
12.txt | AC | 1 ms | 256 KB |
13.txt | AC | 1 ms | 256 KB |
14.txt | AC | 1 ms | 256 KB |
15.txt | AC | 1 ms | 256 KB |
16.txt | TLE | 2103 ms | 256 KB |
17.txt | TLE | 2103 ms | 256 KB |
18.txt | TLE | 2103 ms | 256 KB |
19.txt | TLE | 2103 ms | 256 KB |
20.txt | TLE | 2103 ms | 256 KB |
21.txt | TLE | 2103 ms | 256 KB |
22.txt | TLE | 2103 ms | 256 KB |
23.txt | TLE | 2103 ms | 256 KB |
24.txt | TLE | 2103 ms | 256 KB |
25.txt | TLE | 2103 ms | 256 KB |
26.txt | TLE | 2103 ms | 256 KB |
27.txt | TLE | 2103 ms | 256 KB |
28.txt | TLE | 2103 ms | 256 KB |
29.txt | TLE | 2103 ms | 256 KB |
30.txt | TLE | 2103 ms | 256 KB |
31.txt | TLE | 2103 ms | 256 KB |
32.txt | TLE | 2103 ms | 256 KB |
33.txt | AC | 1 ms | 256 KB |
34.txt | TLE | 2103 ms | 256 KB |
35.txt | TLE | 2103 ms | 256 KB |
36.txt | TLE | 2103 ms | 256 KB |
37.txt | TLE | 2103 ms | 256 KB |
38.txt | TLE | 2103 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |