标签:
input | output |
---|---|
A1A
|
22
|
Problem Author: Igor Goldberg
Problem Source: Tetrahedron Team Contest May 2001
思路:从小到大暴力,注意年龄 >= 2
#include <iostream> #include <sstream> #include <fstream> #include <string> #include <vector> #include <deque> #include <queue> #include <stack> #include <set> #include <map> #include <algorithm> #include <functional> #include <utility> #include <bitset> #include <cmath> #include <cstdlib> #include <ctime> #include <cstdio> #include <string> using namespace std; int N, T; int main() { //freopen("in.txt", "r", stdin); string s; cin >> s; int cnt = 2; for(int i = 0; i < s.size(); i++){ if(s[i] >= ‘A‘ && s[i] <= ‘Z‘ && s[i] - ‘A‘ + 10 >= cnt){ cnt = s[i] - ‘A‘ + 11; }else if(s[i] >= ‘0‘ && s[i] <= ‘9‘&& s[i] - ‘0‘ >= cnt){ cnt = s[i] - ‘0‘ + 1; } } long long int sum = 0, now; for(int k = cnt; k <= 36; k++){ if(s[s.size()-1] >= ‘A‘ && s[s.size()-1] <= ‘Z‘) sum = s[s.size()-1] - ‘A‘ + 10; else sum = s[s.size()-1] - ‘0‘; sum %= (k-1); for(int i = s.size()-2; i >= 0; i--){ if(s[i] >= ‘A‘ && s[i] <= ‘Z‘) now = s[i] - ‘A‘ + 10; else now = s[i] - ‘0‘; sum += now*k; sum %= (k-1); } if(sum == 0) { printf("%d\n", k); exit(0); } } printf("No solution.\n"); return 0; }
ural 1104. Don’t Ask Woman about Her Age暴力
标签:
原文地址:http://www.cnblogs.com/cshg/p/5892370.html