結果

問題 No.434 占い
ユーザー miyo2580miyo2580
提出日時 2024-02-08 22:26:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,351 bytes
コンパイル時間 2,230 ms
コンパイル使用メモリ 205,244 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-08 22:26:12
合計ジャッジ時間 4,174 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
6,676 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 3 ms
6,676 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 33 ms
6,676 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 12 ms
6,676 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 33 ms
6,676 KB
testcase_26 AC 18 ms
6,676 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
using Graph = vector<vector<ll>>;
const long long INF = 1LL<<60;
const long long MOD = 1000000007;

ll nCk(ll n,ll k){
    ll res=1;
    chmin(k,n-k);
    rep(i,k){
        res*=(n-i);
        res/=(i+1);
    }
    if(k<0)res=0;
    return res;
}

int main()
{  
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll T;cin>>T;
    rep(ti,T){
      string s;cin>>s;
      bool flg=1;
      ll n=s.size();
      ll ans=0;
      rep(i,n){
        if(s[i]!='0')flg=0;
        ll x=n-1;
        ll y=i;
        vec u,v;
        while(x){
          u.push_back(x%9);
          x/=9;
        }
        rep(j,u.size()){
          v.push_back(y%9);
          y/=9;
        }
        ll now=1;
        rep(j,u.size()){
          now*=nCk(u[j],v[j]);
          now%=9;
        }
        now*=s[i]-'0';
        now%=9;
        ans+=now;
      }
      ans%=9;
      if(flg==0&&ans==0)ans=9;
      cout<<ans<<'\n';
    }
    return 0;
}
0