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. Elasticsearch.Net 异常:[match] query doesn't support multiple fields, found [field] and [query]

    用Elasticsearch.Net检索数据,报异常: )); ElasticLowLevelClient client = new ElasticLowLevelClient(settings); ...

  2. Python 日志记录与程序流追踪(基础篇)

    日志记录(Logging) More than print: 每次用 terminal debug 时都要手动在各种可能出现 bug 的地方 print 相关信息来确认 bug 的位置: 每次完成 d ...

  3. drupal CVE-2018-7600 复现

    1.系统环境 Drupal 8.5 linux 主机 ruby 代码 2.原理说明 影响版本 Drupal 6.x,7.x,8.x 参考:CVE-2018-7600漏洞分析 3.利用 在Python2 ...

  4. Spark入门(Python)

    Hadoop是对大数据集进行分布式计算的标准工具,这也是为什么当你穿过机场时能看到”大数据(Big Data)”广告的原因.它已经成为大数据的操作系统,提供了包括工具和技巧在内的丰富生态系统,允许使用 ...

  5. underscore.js源码解析(五)—— 完结篇

    最近公司各种上线,所以回家略感疲惫就懒得写了,这次我准备把剩下的所有方法全部分析完,可能篇幅过长...那么废话不多说让我们进入正题. 没看过前几篇的可以猛戳这里: underscore.js源码解析( ...

  6. 王者荣耀交流协会-Alpha发布用户使用报告

    用户数量:10人 姓名如下(包括化名):张小斌.王瑞瑞.蛋蛋.小美.晨曦.小丽.张利刚.小闫.小谢.小崔 寻找的用户多为王者荣耀交流协会成员的同学,对管理时间有着强烈的需求,也对PSP Daily软件 ...

  7. lintcode-420-报数

    420-报数 报数指的是,按照其中的整数的顺序进行报数,然后得到下一个数.如下所示: 1, 11, 21, 1211, 111221, ... 1 读作 "one 1" -> ...

  8. size和STL中的size_type

    为了使自己的程序有很好的移植性,c++程序员应该尽量使用size_t和size_type而不是int, unsigned 1. size_t是全局定义的类型:size_type是STL类中定义的类型属 ...

  9. (转)elasticsearch5.2.2 压测配置

    1.elasticsearch.yml # ---------------------------------- Cluster ----------------------------------- ...

  10. 虚拟机Centos设置静态IP

    首先确保虚拟网卡(VMware Network Adapter VMnet8)是开启的,然后在windows的命令行里输入“ipconfig /all”,找到VMware Network Adapte ...