Submission #41975512
Source Code Expand
Copy
#include <bits/stdc++.h>using namespace std;#define mp make_pair#define pb push_back#define int long long#define pii pair<int, int>#define fi first#define se second#define all(v) v.begin(), v.end()#define trace(x) cout << '>' << #x << ':' << x << "\n"#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << "\n"#define trace3(a,b,c) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"#define trace4(a,b,c,d) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"template <typename T>void print(T var){cout << var << ' ';return;
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define int long long #define pii pair<int, int> #define fi first #define se second #define all(v) v.begin(), v.end() #define trace(x) cout << '>' << #x << ':' << x << "\n" #define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << "\n" #define trace3(a,b,c) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n" #define trace4(a,b,c,d) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n" template <typename T> void print(T var){ cout << var << ' '; return; } template <typename T> void print(vector <T> var){ for (auto x: var) print(x); cout << "\n"; return; } int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, -1, 0, 1}; const int mod = 998244353; bool prime(int x) { if (x==1) return true; for (int i = 2; i*i <= x; i++) { if (x%i==0) return false; } return true; } int f(int a, int b) { if (b==0) return 1; int res = f(a,b/2); res = (res*res) % mod; if (b&1) res = (a*res) % mod; return res; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; string s; cin >> s; vector<int> dp(n+1,0); int ans = 0; for (int i = 1; i < n; i++) { // if (!prime(i)) continue; if (n%i!=0) continue; vector<bool> v(i,false); for (int j = 0; j < n; j++) { if (s[j]=='.') { int cur = j%i; v[cur] = true; } } int c = 0; for (int j = 0; j < i; j++) { if (v[j]) c++; } // trace2(i,i-c); dp[i] = (dp[i]+f(2,i-c)) % mod; for (int j = 2*i; j <= n; j+= i) { dp[j] -= dp[i]; dp[j] += mod; dp[j] %= mod; } } for (int i = 1; i < n; i++) { // if (!prime(i)) continue; if (n%i!=0) continue; ans = (ans+dp[i]) % mod; ans = (ans+mod) % mod; } cout << ans; }
Submission Info
Submission Time | |
---|---|
Task | F - Shift Table |
User | Nur47 |
Language | C++ (GCC 9.2.1) |
Score | 525 |
Code Size | 2190 Byte |
Status | AC |
Exec Time | 98 ms |
Memory | 4236 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 525 / 525 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample00.txt, sample01.txt, sample02.txt |
All | sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt, testcase29.txt, testcase30.txt, testcase31.txt, testcase32.txt, testcase33.txt, testcase34.txt, testcase35.txt, testcase36.txt, testcase37.txt, testcase38.txt, testcase39.txt, testcase40.txt, testcase41.txt, testcase42.txt, testcase43.txt, testcase44.txt, testcase45.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample00.txt | AC | 3 ms | 3544 KB |
sample01.txt | AC | 2 ms | 3556 KB |
sample02.txt | AC | 2 ms | 3468 KB |
testcase00.txt | AC | 2 ms | 3588 KB |
testcase01.txt | AC | 2 ms | 3560 KB |
testcase02.txt | AC | 20 ms | 3884 KB |
testcase03.txt | AC | 70 ms | 3940 KB |
testcase04.txt | AC | 17 ms | 3928 KB |
testcase05.txt | AC | 74 ms | 3860 KB |
testcase06.txt | AC | 17 ms | 3940 KB |
testcase07.txt | AC | 24 ms | 3916 KB |
testcase08.txt | AC | 16 ms | 3920 KB |
testcase09.txt | AC | 98 ms | 3856 KB |
testcase10.txt | AC | 8 ms | 3652 KB |
testcase11.txt | AC | 13 ms | 3544 KB |
testcase12.txt | AC | 16 ms | 3676 KB |
testcase13.txt | AC | 55 ms | 3616 KB |
testcase14.txt | AC | 18 ms | 4176 KB |
testcase15.txt | AC | 22 ms | 3592 KB |
testcase16.txt | AC | 13 ms | 3860 KB |
testcase17.txt | AC | 60 ms | 3864 KB |
testcase18.txt | AC | 8 ms | 3708 KB |
testcase19.txt | AC | 87 ms | 4180 KB |
testcase20.txt | AC | 3 ms | 3508 KB |
testcase21.txt | AC | 22 ms | 3652 KB |
testcase22.txt | AC | 13 ms | 3944 KB |
testcase23.txt | AC | 6 ms | 3508 KB |
testcase24.txt | AC | 5 ms | 3612 KB |
testcase25.txt | AC | 55 ms | 3884 KB |
testcase26.txt | AC | 4 ms | 3672 KB |
testcase27.txt | AC | 5 ms | 3540 KB |
testcase28.txt | AC | 11 ms | 3736 KB |
testcase29.txt | AC | 25 ms | 3648 KB |
testcase30.txt | AC | 9 ms | 4140 KB |
testcase31.txt | AC | 11 ms | 4128 KB |
testcase32.txt | AC | 14 ms | 4128 KB |
testcase33.txt | AC | 14 ms | 4076 KB |
testcase34.txt | AC | 12 ms | 4088 KB |
testcase35.txt | AC | 43 ms | 4176 KB |
testcase36.txt | AC | 11 ms | 4116 KB |
testcase37.txt | AC | 33 ms | 4236 KB |
testcase38.txt | AC | 7 ms | 4232 KB |
testcase39.txt | AC | 7 ms | 4204 KB |
testcase40.txt | AC | 6 ms | 4176 KB |
testcase41.txt | AC | 8 ms | 4124 KB |
testcase42.txt | AC | 17 ms | 3940 KB |
testcase43.txt | AC | 94 ms | 3940 KB |
testcase44.txt | AC | 17 ms | 3936 KB |
testcase45.txt | AC | 39 ms | 4120 KB |