結果

問題 No.83 最大マッチング
ユーザー nyro2
提出日時 2018-01-17 09:28:22
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 642 bytes
コンパイル時間 388 ms
コンパイル使用メモリ 54,992 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 06:38:59
合計ジャッジ時間 3,167 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdlib>

int mypow(int num, int times) {
    int ans = 1;
    
    if (times == 0)
        return 1;
    
    for (int i=0; i<times; i++) {
        ans *= num;
    }
    
    return ans;
}

int main()
{
    int num;
    int i;
    int ans = 0;
    std::cin >> num;

    if (num % 2 == 0) {
        num /= 2;
        for (i=1; i<=num; i++) {
            ans += mypow(10, i-1);
        }
    } else {
        num /= 2;
        for (i=1; i<=num; i++) {
            ans += mypow(10, i-1);
            if (i == num)
                ans += 6 * mypow(10, i-1);
        }
    }
    
    std::cout << ans << std::endl;
}
0