結果
| 問題 |
No.1632 Sorting Integers (GCD of M)
|
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2021-07-30 22:15:57 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,353 bytes |
| コンパイル時間 | 3,092 ms |
| コンパイル使用メモリ | 181,456 KB |
| 最終ジャッジ日時 | 2025-01-23 12:02:15 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 21 WA * 38 |
ソースコード
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint1000000007;
ll powmod(ll a, ll k, ll MOD){
ll ap=a, ans=1;
while(k){
if(k&1){
ans*=ap;
ans%=MOD;
}
ap=ap*ap;
ap%=MOD;
k>>=1;
}
return ans;
}
int main()
{
int n; cin>>n;
ll c[10];
int k=0;
for(int i=1; i<=9; i++){
cin>>c[i];
if(c[i]) k++;
}
if(k==1){
for(int i=1; i<=9; i++){
if(c[i]){
mint ans=(mint(10).pow(n)-1)/9*i;
cout<<ans.val()<<endl;
}
}
return 0;
}
int g=0, pr=-1;
for(int i=1; i<=9; i++){
if(c[i] && pr==-1){
pr=i;
}else if(c[i]){
g=gcd(g, i-pr);
}
}
g*=9;
int r=(powmod(10, n, 9*g)+9*g-1)*pr%(9*g)/9;
g=gcd(r, g);
cout<<g<<endl;
return 0;
}
chocorusk