提出 #7875555


ソースコード 拡げる

Copy
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

const ll MOD = 998244353;

ll powmod(ll x, ll n, ll m)
{
    ll r = 1;
    ll a = x % m;
    while (n>0)
    {
        if (n & 1)
            r = (r*a)%m;
        a = (a*a)%m;
        n = n >> 1;
    }
    return r;
}

pair<ll, ll> f(string& s, int n){
    return make_pair(0ll, 0ll);
}

ll cvt(string& s){
    ll rez = 0;
    for(char c : s){
        rez = (2*rez + c-'0')%MOD;
    }
    return rez+1;
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int n;
    cin >> n;
    string s;
    cin >> s;

    ll sol = 0;
    sol = cvt(s) * 2 * n % MOD;
    for(int d = 1; d<=n; d++){
        if (n%d==0){
            string s2 = s.substr(0, d);
            for(int k=0; k<n/d; k++){
                s2 = min(s2, s.substr(k*d, d));
            }
            ll a = cvt(s2);
            sol += MOD - a * 2 * n % MOD;
            sol += a * 2 * d % MOD;
            sol %= MOD;
        }
    }
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

提出情報

提出日時
問題 C - Division by Two with Something
ユーザ robertv
言語 C++14 (GCC 5.4.1)
得点 0
コード長 1609 Byte
結果 WA
実行時間 108 ms
メモリ 976 KB

コンパイルエラー

./Main.cpp: In function ‘int main(int, char**)’:
./Main.cpp:41:62: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
         freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
                                                              ^

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 800
結果
AC × 1
WA × 2
AC × 6
WA × 43
セット名 テストケース
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, 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, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, s1.txt, s2.txt, s3.txt
ケース名 結果 実行時間 メモリ
01.txt WA 50 ms 920 KB
02.txt WA 34 ms 916 KB
03.txt WA 12 ms 848 KB
04.txt WA 65 ms 788 KB
05.txt WA 19 ms 976 KB
06.txt WA 20 ms 848 KB
07.txt WA 13 ms 848 KB
08.txt WA 22 ms 592 KB
09.txt AC 14 ms 916 KB
10.txt WA 23 ms 848 KB
11.txt WA 53 ms 920 KB
12.txt WA 36 ms 788 KB
13.txt WA 13 ms 848 KB
14.txt WA 34 ms 788 KB
15.txt WA 20 ms 976 KB
16.txt WA 21 ms 848 KB
17.txt WA 14 ms 848 KB
18.txt WA 23 ms 592 KB
19.txt WA 15 ms 916 KB
20.txt WA 24 ms 848 KB
21.txt WA 108 ms 920 KB
22.txt WA 33 ms 788 KB
23.txt WA 12 ms 848 KB
24.txt WA 31 ms 788 KB
25.txt WA 18 ms 976 KB
26.txt WA 20 ms 848 KB
27.txt WA 13 ms 848 KB
28.txt WA 21 ms 592 KB
29.txt AC 14 ms 916 KB
30.txt WA 23 ms 848 KB
31.txt WA 50 ms 920 KB
32.txt WA 33 ms 788 KB
33.txt WA 12 ms 848 KB
34.txt WA 31 ms 788 KB
35.txt WA 19 ms 976 KB
36.txt WA 20 ms 848 KB
37.txt WA 13 ms 848 KB
38.txt WA 21 ms 592 KB
39.txt AC 14 ms 916 KB
40.txt WA 23 ms 848 KB
41.txt WA 50 ms 920 KB
42.txt WA 33 ms 788 KB
43.txt AC 1 ms 256 KB
44.txt AC 1 ms 256 KB
45.txt WA 1 ms 256 KB
46.txt WA 1 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt WA 1 ms 256 KB
s3.txt WA 1 ms 256 KB