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
  1. 6
Output
  1. six
Input
  1. 99
Output
  1. ninety-nine
Input
  1. 20
Output
  1. twenty
Note

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

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

题解:标记一下。

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll __int64
  4. int n;
  5. map<int,string> mp;
  6. int main()
  7. {
  8. scanf("%d",&n);
  9. mp[]="zero";
  10. mp[]="one";
  11. mp[]="two";
  12. mp[]="three";
  13. mp[]="four";
  14. mp[]="five";
  15. mp[]="six";
  16. mp[]="seven";
  17. mp[]="eight";
  18. mp[]="nine";
  19. mp[]="ten";
  20. mp[]="eleven";
  21. mp[]="twelve";
  22. mp[]="thirteen";
  23. mp[]="fourteen";
  24. mp[]="fifteen";
  25. mp[]="sixteen";
  26. mp[]="seventeen";
  27. mp[]="eighteen";
  28. mp[]="nineteen";
  29. mp[]="twenty";
  30. mp[]="thirty";
  31. mp[]="forty";
  32. mp[]="fifty";
  33. mp[]="sixty";
  34. mp[]="seventy";
  35. mp[]="eighty";
  36. mp[]="ninety";
  37. if(n<=)
  38. cout<<mp[n]<<endl;
  39. else
  40. {
  41. int a,b;
  42. a=n/;
  43. b=n%;
  44. if(b>)
  45. cout<<mp[a*]<<"-"<<mp[b]<<endl;
  46. else
  47. cout<<mp[a*]<<endl;
  48. }
  49. return ;
  50. }
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
  1. 4
Output
  1. 1
Input
  1. 7
Output
  1. 2
Input
  1. 77
Output
  1. 6
    题意:求小于等于的n的数中 只含有47的数字的个数
    题解:dfs一下
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll __int64
  4. ll n;
  5. ll sum=;
  6. void dfs(ll x)
  7. {
  8. if(x<=n)
  9. sum++;
  10. else
  11. return ;
  12. dfs(x*+);
  13. dfs(x*+);
  14. }
  15. int main()
  16. {
  17. scanf("%I64d",&n);
  18. dfs();
  19. dfs();
  20. printf("%I64d\n",sum);
  21. return ;
  22. }
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
  1. 2 1 4
    1 5 3
    3 3 10
    7 10 2
    6 4 8
Output
  1. 4
    -1
    8
    -1
Input
  1. 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   
二分右端点;
 
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll __int64
  4. ll a,b,n;
  5. ll l,t,m;
  6. bool fun(int x)
  7. {
  8. ll shou=a+(l-)*b;
  9. ll exm=a+(x-)*b;
  10. ll sum=(shou+exm)*(x-l+)/;
  11. if(exm<=t&&sum<=t*m)
  12. return true;
  13. else
  14. return false;
  15. }
  16. int main()
  17. {
  18. scanf("%I64d %I64d %I64d",&a,&b,&n);
  19. for(int i=;i<=n;i++)
  20. {
  21. scanf("%I64d %I64d %I64d",&l,&t,&m);
  22. ll left=l,right=1e6+,mid;
  23. ll flag=;
  24. while(left<=right)
  25. {
  26. mid=(left+right)/;
  27. if(fun(mid)){
  28. left=mid+;
  29. flag=;
  30. }
  31. else
  32. right=mid-;
  33. }
  34. if(flag==)
  35. printf("-1\n");
  36. else
  37. printf("%I64d\n",right);
  38. }
  39. return ;
  40. }

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. 【转载】IntelliJ IDEA 2017常用快捷键

    IntelliJ IDEA 是一款致力于提供给开发工程师沉浸式编程体验的IDE工具,所以在其中提供了很多方便高效的快捷键,一旦熟练掌握,整个开发的效率和体验将大大提升.本文就按照笔者自己日常开发时的使 ...

  2. 01_基于TCP的循环为同一个客户端下载文件的下载器

    原版: TCP分为客户端(client)和服务器(server),每次服务器只能为客户端提供一次的下载服务. 改良版: TCP分为客户端(client)和服务器(server), (1)每次服务器能为 ...

  3. Fedora 26/27/28网易云音乐安装

    信息从 https://www.southcity-oldboy.com/1474.html获取,感谢站长南城旧少年! 以下为前辈网页上的内容 1.安装 RPM Fusion 源 (free): ht ...

  4. 微软职位内部推荐-Principal Group Program Manager

    微软近期Open的职位: Standard job title: Principal Group Program Manager Discipline: Program Management Prod ...

  5. css 元素水平垂直方向居中

    html部分 <div class="parent"> <div class="child"> - -居中- - </div> ...

  6. Java 学习笔记 ------第五章 对象封装

    本章学习目标: 了解封装的概念与实现 定义类.构造函数与方法 使用方法重载与不定长度自变量 了解static方法 一.Java封装概念 在面向对象程式设计方法中,封装(英语:Encapsulation ...

  7. BETA事后总结

    目录 所有成员 项目宣传视频链接 贡献比例 工作流程 组员分工 本组 Beta 冲刺站立会议博客链接汇总 燃尽图 原计划.达成情况及原因分析 组员:胡绪佩 组员:周政演 组员:庄卉 组员:何家伟 组员 ...

  8. 关于mysql无法添加中文数据的问题以及解决方案

    今天弄了一天的mysql数据库,就是被一个mysql数据库乱码的问题给缠住了.现在记录一下这个问题,虽然这个问题不是什么太大的事情,但还是记录一下. 问题是这样的: 1.先在mysql的安装文件当中, ...

  9. Dijkstra+优先队列 模板

    #include<bits/stdc++.h> using namespace std; #define ll long long ; const ll inf=1e17; struct ...

  10. Struts2(七)

    以下内容是基于导入struts2-2.3.32.jar包来讲的 1.xml验证 Struts2提供了验证器,实现了通用的验证逻辑.例如: 非空验证器.长度验证器.日期验证器.email验证器等.具体定 ...