結果

問題 No.796 well known
ユーザー KotRmKotRm
提出日時 2019-03-15 23:22:24
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,246 bytes
コンパイル時間 421 ms
コンパイル使用メモリ 53,292 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-14 14:17:56
合計ジャッジ時間 3,183 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:9: warning: ‘V[2]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     int V[3];
         ^
main.cpp:17:9: warning: ‘V[1]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
main.cpp:17:9: warning: ‘V[0]’ may be used uninitialized in this function [-Wmaybe-uninitialized]

ソースコード

diff #

#include <iostream>
#include <string>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define printn(x) cout << x << " ";
#define print(x) cout << x << endl;
using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    
    int c, sum, flag;
    int V[3];
    sum = 0;
    flag = 0;
    FOR(a, 1, N){
        REP(b, N-a){
            c = N - a - b;
            if((b+2*c)%3==1){
                FOR(i, 1, a+1){
                    sum += 3*i;
                }
                FOR(i, 0, b){
                    sum += (3*i + 1);
                }
                FOR(i, 0, c){
                    sum += (3*i + 2);
                }
                if(sum <= 312456){
                    V[0] = a;
                    V[1] = b;
                    V[2] = c;
                    flag = 1;
                    break;
                }
            }
        }
        if(flag == 1){
            break;
        }
    }
    
    string ans = "";
    FOR(a, 1, V[0]+1){
        printn(3*a);
    }
    REP(b, V[1]){
        printn(3*b + 1);
    }
    REP(b, V[2]){
        printn(3*b + 2);
    }
    print("");
    return 0;
}
0