Codeforces Round #299 (Div. 2) A. Tavas and Nafas 水题
A. Tavas and Nafas
Time Limit: 1 Sec Memory Limit: 256 MB
题目连接
http://codeforces.com/contest/535/problem/ADescription
Today Tavas got his test result as an integer score and he wants to share it with his girlfriend, Nafas.
His phone operating system is Tavdroid, and its keyboard doesn't have any digits! He wants to share his score with Nafas via text, so he has no choice but to send this number using words.
He ate coffee mix without water again, so right now he's really messed up and can't think.
Your task is to help him by telling him what to type.
Input
The first and only line of input contains an integer s (0 ≤ s ≤ 99), Tavas's score.
1000000000.Output
In the first and only line of output, print a single string consisting only from English lowercase letters and hyphens ('-'). Do not use spaces.
Sample Input
6
Sample Output
six
HINT
题意
给你100以下数字,输出英文题解:
代码:
//qscqesze #include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algorithm> #include <set> #include <vector> #include <sstream> #include <queue> #include <typeinfo> #include <fstream> #include <map> #include <stack> typedef long long ll; using namespace std; //freopen("D.in","r",stdin); //freopen("D.out","w",stdout); #define sspeed ios_base::sync_with_stdio(0);cin.tie(0) #define maxn 200001 #define mod 10007 #define eps 1e-9 //const int inf=0x7fffffff; //无限大 const int inf=0x3f3f3f3f; /* int buf[10]; inline void write(int i) { int p = 0;if(i == 0) p++; else while(i) {buf[p++] = i % 10;i /= 10;} for(int j = p-1; j >=0; j--) putchar('0' + buf[j]); printf("\n"); } */ //************************************************************************************** inline ll read() { int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } map<int,string> s; int main() { int n=read(); s[1]="one"; s[2]="two"; s[3]="three"; s[4]="four"; s[5]="five"; s[6]="six"; s[7]="seven"; s[8]="eight"; s[9]="nine"; s[10]="ten"; s[11]="eleven"; s[12]="twelve"; s[13]="thirteen"; s[14]="fourteen"; s[15]="fifteen"; s[16]="sixteen"; s[17]="seventeen"; s[18]="eighteen"; s[19]="nineteen"; s[20]="twenty"; s[30]="thirty"; s[40]="forty"; s[50]="fifty"; s[60]="sixty"; s[70]="seventy"; s[80]="eighty"; s[90]="ninety"; if(n==0) cout<<"zero"<<endl; else if(n<=20) cout<<s[n]<<endl; else if(n%10==0) cout<<s[n]<<endl; else cout<<s[n-n%10]<<"-"<<s[n%10]<<endl; }