結果
| 問題 |
No.1085 桁和の桁和
|
| コンテスト | |
| ユーザー |
auaua
|
| 提出日時 | 2020-06-19 23:05:37 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,103 bytes |
| コンパイル時間 | 1,561 ms |
| コンパイル使用メモリ | 172,296 KB |
| 実行使用メモリ | 13,440 KB |
| 最終ジャッジ日時 | 2024-07-23 00:38:52 |
| 合計ジャッジ時間 | 3,490 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 WA * 3 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define fi first
#define se second
#define vec vector<ll>
#define mat vector<vector<ll> >
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
string t;cin>>t;
ll d;cin>>d;
ll sum=0;
ll cnt=0;
rep(i,t.size()){
if(t[i]=='?')cnt++;
else sum+=(t[i]-'0');
}
if(d==0){
if(sum==0){
cout<<1<<endl;
}else{
cout<<0<<endl;
}
return 0;
}
sum%=9;
d%=9;
vector<vector<ll> >dp(cnt+1,vector<ll>(9));
dp[0][sum]=1;
rep(i,cnt){
rep(j,9){
rep(k,10){
dp[i+1][(j+k)%9]=(dp[i+1][(j+k)%9]+dp[i][j])%mod;
}
//cout<<dp[i][j]<<' ';
}
//cout<<endl;
}
cout<<dp[cnt][d]<<endl;
}
auaua