0062 - What is the Bottommost?
#include <iostream> #include <string> using namespace std; void Slove(string str) { int number[10]; for (int i=0; i<str.length(); ++i) number[i]=str[i]-'0'; for (int i=1; i<=10; ++i) for (int j=1; j<=10-i; ++j) number[j-1]=(number[j-1]+number[j])%10; cout << number[0] << endl; } int main(void) { string str; while (cin >> str) Slove(str); return 0; }
文字列を数字にして計算するだけ。