#299 (div.2) A. Tavas and Nafas

1.题目描述:点击打开链接

2.解题思路:本题是一道简单的模拟题,要求将小于100的每个数的英文单词输出,提前打表即可。注意0,11~19要特殊处理。

3.代码:

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<queue>
#include<deque>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<ctime>
#include<functional>
using namespace std;

#define INF 100000000
#define For(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
char*s[] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
char*t[] = {0, "ten", "twenty", "thirty","forty", "fifty", "sixty", "seventy", "eighty", "ninety" };
char*sp[] = { 0,"eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" };

int main()
{
	//freopen("t.txt", "r", stdin);
	int n;
	while (~scanf("%d", &n))
	{
		int d = 0;
		int x = n;
		while (x > 0){ d++; x /= 10; }
		if (n < 10)
		{
			cout << s[n] << endl;
		}
		else if (n>10&&n < 20){
			cout << sp[n - 10] << endl;
		}
		else if (d == 2 && n % 10 == 0){
			cout << t[n / 10] << endl;
		}
		else if (n>=20&&d == 2 && (n % 10 != 0))
		{
			int x1 = n / 10, x2 = n % 10;
			cout << t[x1]<< '-' << s[x2] << endl;
		}
	}
	return 0;
}
时间: 2024-10-26 15:21:34

#299 (div.2) A. Tavas and Nafas的相关文章

水题 Codeforces Round #299 (Div. 2) A. Tavas and Nafas

题目传送门 1 /* 2 很简单的水题,晚上累了,刷刷水题开心一下:) 3 */ 4 #include <bits/stdc++.h> 5 using namespace std; 6 7 char s1[11][10] = {"zero", "one", "two", "three", "four", "five", "six", "seven

Codeforces Round #299 (Div. 2) A. Tavas and Nafas

题目链接:http://codeforces.com/problemset/problem/535/A #include <iostream> #include <string> using namespace std; int main() { string s1[10]={"zero","one","two","three","four","five",&qu

DFS Codeforces Round #299 (Div. 2) C. Tavas and Karafs

题目传送门 1 /* 2 DFS:按照长度来DFS,最后排序 3 */ 4 #include <cstdio> 5 #include <algorithm> 6 #include <cstring> 7 #include <iostream> 8 #include <cmath> 9 #include <vector> 10 using namespace std; 11 12 const int MAXN = 1e3 + 10; 1

二分搜索 Codeforces Round #299 (Div. 2) C. Tavas and Karafs

题目传送门 1 /* 2 题意:给定一个数列,求最大的r使得[l,r]的数字能在t次全变为0,每一次可以在m的长度内减1 3 二分搜索:搜索r,求出sum <= t * m的最大的r 4 详细解释:http://blog.csdn.net/libin56842/article/details/45082747 5 */ 6 #include <cstdio> 7 #include <algorithm> 8 #include <cstring> 9 #includ

Codeforces Round #299 (Div. 1)C. Tavas and Pashmaks (凸壳)

C. Tavas and Pashmaks Tavas is a cheerleader in the new sports competition named "Pashmaks". This competition consists of two part: swimming and then running. People will immediately start running R meters after they finished swimming exactly S 

Codeforces Round #299 (Div. 2)D. Tavas and Malekas

KMP,先预处理按每个节点标记,扫一遍更新每个匹配位置,最后kmp判断是否有重合而且不相同的地方 注意处理细节,很容易runtime error #include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cassert> #inclu

#299 (div.2) B. Tavas and SaDDas

1.题目描述:点击打开链接 2.解题思路:本题要求找出所给的幸运数的下标.本题类似于紫书上的一道例题ugly number.利用BFS即可解决.首先将4,7入队列,每次出队列后,将数字添加到set,同时将它们的末尾分别添加是4,7后得到新的幸运数入队列即可.上述过程打表后,直接输出即可. 3.代码: #define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<algorithm> #include<string>

Codeforces Round #299 (Div. 2) Tavas and Karafs(二分)

英语渣渣感觉无力...翻了下题解才知道题意... 给你一个无限长的等差数列a,n个查询.对于每个查询,给出l,t,m,求最大的r.表示在等差数列a的第l号元素到第r号元素,执行t次操作,对于每一次操作,在[l,r]区间内选出m个数,并且把这m个数-1,执行完t次操作后,使得区间[l,r]内的数全部为0,求区间最大的右端点r. 如果t小于a[l],那么执行完t次操作a[l]也不会为0,输出-1 那么同理我们可以求出r的范围,r肯定小于等于(t-a)/b,因为数列是递增的. 既然我们都已经知道了范围

【codeforces #299(div 1)】ABC题解

A. Tavas and Karafs time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Karafs is some kind of vegetable in shape of an 1?×?h rectangle. Tavaspolis people love Karafs and they use Karafs in almost