A. Tavas and Nafas
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

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.

Examples
Input
6
Output
six
Input
99
Output
ninety-nine
Input
20
Output
twenty
Note

You can find all you need to know about English numerals in http://en.wikipedia.org/wiki/English_numerals .

题意:将0~99转换为单词表示

题解:标记一下。

 #include<bits/stdc++.h>
using namespace std;
#define ll __int64
int n;
map<int,string> mp;
int main()
{
scanf("%d",&n);
mp[]="zero";
mp[]="one";
mp[]="two";
mp[]="three";
mp[]="four";
mp[]="five";
mp[]="six";
mp[]="seven";
mp[]="eight";
mp[]="nine";
mp[]="ten";
mp[]="eleven";
mp[]="twelve";
mp[]="thirteen";
mp[]="fourteen";
mp[]="fifteen";
mp[]="sixteen";
mp[]="seventeen";
mp[]="eighteen";
mp[]="nineteen";
mp[]="twenty";
mp[]="thirty";
mp[]="forty";
mp[]="fifty";
mp[]="sixty";
mp[]="seventy";
mp[]="eighty";
mp[]="ninety";
if(n<=)
cout<<mp[n]<<endl;
else
{
int a,b;
a=n/;
b=n%;
if(b>)
cout<<mp[a*]<<"-"<<mp[b]<<endl;
else
cout<<mp[a*]<<endl;
}
return ;
}
B. Tavas and SaDDas
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. That's why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas' headphones and told him: "If you solve the following problem, I'll return it to you."

The problem is:

You are given a lucky number n. Lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

If we sort all lucky numbers in increasing order, what's the 1-based index of n?

Tavas is not as smart as SaDDas, so he asked you to do him a favor and solve this problem so he can have his headphones back.

Input

The first and only line of input contains a lucky number n (1 ≤ n ≤ 109).

Output

Print the index of n among all lucky numbers.

Examples
Input
4
Output
1
Input
7
Output
2
Input
77
Output
6
题意:求小于等于的n的数中 只含有4,7的数字的个数
题解:dfs一下
 #include<bits/stdc++.h>
using namespace std;
#define ll __int64
ll n;
ll sum=;
void dfs(ll x)
{
if(x<=n)
sum++;
else
return ;
dfs(x*+);
dfs(x*+);
}
int main()
{
scanf("%I64d",&n);
dfs();
dfs();
printf("%I64d\n",sum);
return ;
}
C. Tavas and Karafs
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs.

Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + (i - 1) × B.

For a given m, let's define an m-bite operation as decreasing the height of at most m distinct not eaten Karafses by 1. Karafs is considered as eaten when its height becomes zero.

Now SaDDas asks you n queries. In each query he gives you numbers l, t and m and you should find the largest number r such that l ≤ r and sequence sl, sl + 1, ..., sr can be eaten by performing m-bite no more than t times or print -1 if there is no such number r.

Input

The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105).

Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.

Output

For each query, print its answer in a single line.

Examples
Input
2 1 4
1 5 3
3 3 10
7 10 2
6 4 8
Output
4
-1
8
-1
Input
1 5 2
1 5 10
2 7 4
Output
1
2
题意:一个很迷的题意 有一个等差数列  从A开始  公差为B  然后n个询问  每个询问给定l,t,m   然后要求如果每次可以最多选择m个数   使这m个数-1   那么在t次操作中可以使l为左端点的最长序列中使所有数为0  输出这个最长序列的右端序号
题解: 序列h1,h2,...,hn 可以在t次时间内(每次至多让m个元素减少1)  全部减小为0  当且仅当 max(h1, h2, ..., hn) <= t  &&  h1 + h2 + ... + hn <= m*t   
二分右端点;
 
 #include<bits/stdc++.h>
using namespace std;
#define ll __int64
ll a,b,n;
ll l,t,m;
bool fun(int x)
{
ll shou=a+(l-)*b;
ll exm=a+(x-)*b;
ll sum=(shou+exm)*(x-l+)/;
if(exm<=t&&sum<=t*m)
return true;
else
return false;
}
int main()
{
scanf("%I64d %I64d %I64d",&a,&b,&n);
for(int i=;i<=n;i++)
{
scanf("%I64d %I64d %I64d",&l,&t,&m);
ll left=l,right=1e6+,mid;
ll flag=;
while(left<=right)
{
mid=(left+right)/;
if(fun(mid)){
left=mid+;
flag=;
}
else
right=mid-;
}
if(flag==)
printf("-1\n");
else
printf("%I64d\n",right);
}
return ;
}

Codeforces Round #299 (Div. 2)A B C 水 dfs 二分的更多相关文章

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

    题目传送门 /* 题意:给定一个数列,求最大的r使得[l,r]的数字能在t次全变为0,每一次可以在m的长度内减1 二分搜索:搜索r,求出sum <= t * m的最大的r 详细解释:http:/ ...

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

    题目传送门 /* 很简单的水题,晚上累了,刷刷水题开心一下:) */ #include <bits/stdc++.h> using namespace std; ][] = {" ...

  3. DFS Codeforces Round #299 (Div. 2) B. Tavas and SaDDas

    题目传送门 /* DFS:按照长度来DFS,最后排序 */ #include <cstdio> #include <algorithm> #include <cstrin ...

  4. Codeforces Round #367 (Div. 2) A. Beru-taxi (水题)

    Beru-taxi 题目链接: http://codeforces.com/contest/706/problem/A Description Vasiliy lives at point (a, b ...

  5. Codeforces Round #603 (Div. 2) A. Sweet Problem(水.......没做出来)+C题

    Codeforces Round #603 (Div. 2) A. Sweet Problem A. Sweet Problem time limit per test 1 second memory ...

  6. Codeforces Round #334 (Div. 2) A. Uncowed Forces 水题

    A. Uncowed Forces Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/pro ...

  7. Codeforces Round #285 (Div. 2) A, B , C 水, map ,拓扑

    A. Contest time limit per test 1 second memory limit per test 256 megabytes input standard input out ...

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

    题目链接: http://codeforces.com/problemset/problem/535/D D. Tavas and Malekas time limit per test2 secon ...

  9. Codeforces Round #299 (Div. 1) A. Tavas and Karafs 水题

    Tavas and Karafs Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/536/prob ...

随机推荐

  1. JY播放器【网易云音乐破解下载】

    今天给大家带来一款神器----JY播放器.可以直接下载网易云音乐的歌曲. 目前已经支持平台(蜻蜓FM.喜马拉雅FM.网易云音乐.QQ音乐) 使用方法: 在电脑打开网易云音乐或者网站找到你要听的歌曲或歌 ...

  2. Spring Cloud(三):服务提供与调用 Eureka【Finchley 版】

    Spring Cloud(三):服务提供与调用 Eureka[Finchley 版]  发表于 2018-04-15 |  更新于 2018-05-07 |  上一篇文章我们介绍了 Eureka 服务 ...

  3. python编辑用户登入界面

    1.需求分析 登入界面需要达到以下要求: 系统要有登入和注册两个选项可供选择 系统要能够实现登入出错提示,比如账户密码错误等,用户信息保存在user_info.txt文件夹中 系统要能够进行登入错误次 ...

  4. 从零开始的Python学习Episode 11——装饰器

    装饰器 装饰器是用来处理其他函数的函数,主要作用是在不修改原有函数的情况下添加新的功能,装饰器的返回值也是一个函数对象. 简单的装饰器 import time def show_time(f): de ...

  5. CDQ分治_占坑

    准备系统地学习一波CDQ分治,持续更新中... 首先,CDQ分治也还是分治的一种,只不过普通分治是独立的解决两个子问题,而CDQ分治还要计算第一个子问题对于第二个的影响. CDQ分治几乎都是用来解决多 ...

  6. We are writing to let you know we have removed your selling privileges

     Hello, We are writing to let you know we have removed your selling privileges, canceled your listin ...

  7. sprint2 团队贡献分

    团队名:在考虑 团队贡献分: 102 杨晶晶:17 106 邹育萍:18 114 纪焓:16 116 黄敏鹏:28 117 郑培轩:26 138 曾昱霖:15 最新项目的github地址: https ...

  8. Python 变量和常量及数据类型

    一.变量的命名 变量由字母.数字和下划线组成.变量的第1个字符必须是字母或下划线. 二.变量的赋值 例: x = 1 三.局部变量 局部变量只能在函数或者代码段内使用. 四.全局变量 在函数之外定义的 ...

  9. arp请求与回复

    实验环境:wifi 1,手机192.168.1.103 2,电脑192.168.1.106 先删除电脑arp表数据 ping request: reply:

  10. GO语言教程(一)Linux( Centos)下Go的安装, 以及HelloWorld

    写在前面: 目前,Go语言已经发布了1.5的版本,已经有不少Go语言相关的书籍和教程了,但是看了一些后,觉得还是应该自己写一套Go语言的教程.给广大学习Go语言的朋友多一种选择.因为,咱写的教程,向来 ...