結果
| 問題 |
No.2593 Reorder and Mod 120
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-12-21 22:09:43 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 859 bytes |
| コンパイル時間 | 1,912 ms |
| コンパイル使用メモリ | 196,120 KB |
| 最終ジャッジ日時 | 2025-02-18 13:07:59 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n, sumv = 0, v;
string s;
cin >> n >> s;
if(n <= 2){
cout << 1 + (s[0] != s.back()) << '\n';
return 0;
}
array<int, 10> cnt{};
vector<bool> used(120);
for(auto &&c : s){
v = c - '0';
cnt[v]++;
sumv += v;
}
sumv *= 40;
for(int i = 0; i < 10; i++){
if(cnt[i] == 0) continue;
cnt[i]--;
for(int j = 0; j < 10; j++){
if(cnt[j] == 0) continue;
cnt[j]--;
for(int k = 0; k < 10; k++){
if(cnt[k]) used[(sumv - 40 * (i + j + k) + 100 * i + 10 * j + k) % 120] = true;
}
cnt[j]++;
}
cnt[i]++;
}
cout << count(used.begin(), used.end(), true) << '\n';
}