結果
| 問題 |
No.432 占い(Easy)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-14 23:05:33 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 2,073 bytes |
| コンパイル時間 | 1,788 ms |
| コンパイル使用メモリ | 162,960 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-22 09:41:51 |
| 合計ジャッジ時間 | 2,556 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
// macros
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define INT_IN(a) int a; cin >> a
#define STR_IN(s) string s; cin >> s
#define PRINTLN(s) cout << s << endl
#define PRINTDOUBLELN(s) cout << setprecision(12) << (s) << endl;
// util functions
template<class T> inline T sqr(T x) {return x*x;}
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template <typename T>inline T max(vector<T> v){T max=v[0]; FOR(i, 1, v.size())max=MAX(v[i], max); return max;}
template <typename T>inline T min(vector<T> v){T min=v[0]; FOR(i, 1, v.size())min=MIN(v[i], min); return min;}
template <typename T>inline vector<T> concat(vector<T> a, vector<T> b){vector<T> ab; ab.reserve(a.size()+b.size());ab.insert(ab.end(),a.begin(),a.end());ab.insert(ab.end(),b.begin(),b.end());return ab;}
// types
typedef long long LL;
// consts
const double EPS = 1e-10;
const double PI = acos(-1.0);
//debug
#define dump(x) #x << " = " << (x) << endl
#define debug(x) #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
int combination(int n, int r){
if(n == r) return 1;
if((r << 1) > n) r = n - r;
if(r == 0) return 1;
int res = n;
FOR(i, 2, r + 1){
res *= n - i + 1;
res /= i;
}
return res;
}
int main(){
INT_IN(T);
REP(i, T){
STR_IN(S);
int l = S.length();
if(l == 1){
PRINTLN(S);
}else{
vector<int> iS;
REP(j, l){
iS.push_back(S[j] - '0');
}
while(l-- > 1){
vector<int> niS;
REP(j, l){
int s = iS[j] + iS[j + 1];
if(s > 9)s -= 9;
niS.push_back(s);
}
iS = niS;
}
PRINTLN(iS[0]);
}
}
return 0;
}