結果

問題 No.434 占い
ユーザー tossy
提出日時 2016-10-14 23:36:10
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,043 bytes
コンパイル時間 2,380 ms
コンパイル使用メモリ 90,908 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-22 06:33:54
合計ジャッジ時間 2,075 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 9 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

int main(){
  int tc;
  scanf("%d\n", &tc);
  rep(loops, tc){
    vector<int> vec;
    char c;
    while(scanf("%c", &c)){
      if(c=='\n') break;
      vec.pb(c-'0');
    }
    int n =vec.size();

    long res = 0;
    long ue=n-1, shita=1;
    long cc=1;
    rep(i,n){
      res += vec[i] * cc;
      cc = cc * ue / shita;
      ue--; shita++;
    }

    long ans=0;
    while(res>=10){
      ans=0;
      while(res>0){ ans+=res%10; res/=10;}
      res = ans;
    }
    printf("%d\n", res);

  }

  return 0;
}
0