codeforces 535A-水题;

#include <bits/stdc++.h>
using namespace std;
typedef long long LL; char s2[15][20]={"eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};
char s1[15][20]={"ten","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"};
char s3[15][20]={"one","two","three","four","five","six","seven","eight","nine"}; int main()
{ int n;
scanf("%d",&n);
if(n==0)
{
puts("zero");
return 0;
}
if(n>=10)
{
if(n%10==0)
printf("%s",s1[n/10-1]);
else if((n/10)==1)
printf("%s",s2[n%10-1]);
else
printf("%s-%s",s1[n/10-1],s3[n%10-1]);
}
else
printf("%s",s3[n%10-1]); return 0;
}

codeforces 535B

最多才2^9个数,直接预处理,然后找一遍。

#include <bits/stdc++.h>
using namespace std;
typedef long long LL; LL p[1000000]; LL Pow(int k)
{
LL ans=1;
for(int i=1;i<=k;i++)
ans=ans*10LL;
return ans;
}
int num;
void init()
{ LL k;
p[0]=4LL;
p[1]=7LL;
num=2;
bool flag=false;
for(int i=1;i<=9;i++)
{
int t=0;
k=Pow(i);
for(int j=0;j<num;j++)
{
if(p[j]*10<k) continue;
p[num+t]=k*4LL+p[j];
if(p[num+t]>1000000000)
{
num=num+t;
flag=true;
break;
}
t++;
p[num+t]=k*7LL+p[j];
if(p[num+t]>1000000000)
{
num+=t;
flag=true;
break;
}
t++;
}
if(flag) break;
num=num+t;
}
} int main()
{
init();
LL n;
scanf("%lld",&n);
sort(p,p+num);
for(int i=0;i<num;i++)
{
if(p[i]==n)
{
printf("%d\n",i+1);
return 0;
}
}
return 0;
}

codeforces 535C:题意:

给等差数列:首项A,公差B,n个询问

每个询问 给l,t,m

以l为左端点,每次可以最多选择m个数,使这些数 -1   

t次操作后,求最长序列使所有数为0,输出这个最长序列的右端序号

思路:

二分对吧。

那么就去找二分的满足条件对吧。

首先数列里面最大的数肯定<=t,对勾

数列里面所有的数相加和<=t*m 对勾

然后二分 11111100000型 对勾

#include <cstdio>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long LL;
int n;
LL a,b,t,m; LL sum[1000100];
void init()
{
sum[0]=0;
sum[1]=a;
for(LL i=2;i<=1000000;i=i+1LL)
sum[i]=sum[i-1]+a+(i-1LL)*b;
} int main()
{
LL tmp;
scanf("%I64d%I64d%I64d",&a,&b,&n);
init();
while(n--)
{
scanf("%I64d%I64d%I64d",&tmp,&t,&m);
LL left=tmp,right=1000000;
while(left<right)
{
LL mid=left+(right-left+1LL)/2LL;
if((a+(mid-1LL)*b)<=t&&(sum[mid]-sum[tmp-1])<=t*m)
left=mid;
else
right=mid-1LL;
}
if((a+(left-1LL)*b)<=t&&(sum[left]-sum[tmp-1])<=t*m)
printf("%I64d\n",left);
else
puts("-1");
}
return 0;
}
/*
2 1 4
1 5 3
3 3 10
7 10 2
6 4 8
*/

Codeforces Round #299 (Div. 2)【A,B,C】的更多相关文章

  1. 【CF1256】Codeforces Round #598 (Div. 3) 【思维+贪心+DP】

    https://codeforces.com/contest/1256 A:Payment Without Change[思维] 题意:给你a个价值n的物品和b个价值1的物品,问是否存在取物方案使得价 ...

  2. Codeforces Round #331 (Div. 2)【未完待续】

    http://codeforces.com/problemset/problem/596/B GGGGGGGGGGGGGGGGGGG

  3. Codeforces Round #493 (Div. 2) 【A,B,C】

    简单思维题 #include<bits/stdc++.h> using namespace std; #define int long long #define inf 0x3f3f3f3 ...

  4. Codeforces Round #609 (Div. 2) 【A,B,C】

    题意:给一个n<=1e7,找两个合数a和b使得a-b的差为n. 构造a=3n,b=2n,必含有公因子n,只有当n是1的时候是特例. #include<bits/stdc++.h> u ...

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

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

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

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

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

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

  8. Codeforces Round #443 (Div. 2) 【A、B、C、D】

    Codeforces Round #443 (Div. 2) codeforces 879 A. Borya's Diagnosis[水题] #include<cstdio> #inclu ...

  9. Codeforces Round #436 (Div. 2)【A、B、C、D、E】

    Codeforces Round #436 (Div. 2) 敲出一身冷汗...感觉自己宛如智障:( codeforces 864 A. Fair Game[水] 题意:已知n为偶数,有n张卡片,每张 ...

随机推荐

  1. python网络爬虫之初识网络爬虫

    第一次接触到python是一个很偶然的因素,由于经常在网上看连载小说,很多小说都是上几百的连载.因此想到能不能自己做一个工具自动下载这些小说,然后copy到电脑或者手机上,这样在没有网络或者网络信号不 ...

  2. SQL join中级篇--hive中 mapreduce join方法分析

    1. 概述. 本文主要介绍了mapreduce框架上如何实现两表JOIN. 2. 常见的join方法介绍 假设要进行join的数据分别来自File1和File2. 2.1 reduce side jo ...

  3. Android LinearLayout线性布局

    LinearLayout是线性布局控件:要么横向排布,要么竖向排布 决定性属性:必须有的! android:orientation:vertical (垂直方向) .horizontal(水平方向) ...

  4. BZOJ1833 数位DP

    数位DP随便搞搞. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstrin ...

  5. PYTHON 爬虫笔记六:PyQuery库基础用法

    知识点一:PyQuery库详解及其基本使用 初始化 字符串初始化 html = ''' <div> <ul> <li class="item-0"&g ...

  6. 线程池ThreadPool的常用方法介绍

    线程池ThreadPool的常用方法介绍 如果您理解了线程池目的及优点后,让我们温故下线程池的常用的几个方法: 1. public static Boolean QueueUserWorkItem(W ...

  7. swoole的http服务

    PHP实现基于Swoole简单的HTTP服务器 引用Swoole官方定义: PHP语言的异步.并行.高性能网络通信框架,使用纯C语言编写,提供了PHP语言的异步多线程服务器,异步TCP/UDP网络客户 ...

  8. 改变Ecplise项目窗口字体样式

    Eclipse\plugins\org.eclipse.ui.themes_1.1.1.v20151026-1355\css e4-dark_win.css CTabFolder Tree, CTab ...

  9. linux命令学习笔记(52):ifconfig命令

    许多windows非常熟悉ipconfig命令行工具,它被用来获取网络接口配置信息并对此进行修改.Linux系统拥有 一个类似的工具,也就是ifconfig (interfaces config).通 ...

  10. BZOJ4278 [ONTAK2015]Tasowanie[后缀数组+贪心]

    题目 求两数组归并后的数组最小字典序排列. 嘛,可能本人在贪心这块还是太弱了(或者说什么都弱),如果不知道是字符串题估计也想不起来用sa. 显然看得出归并时字典序小的那个数组先往里面加,这就是要比较两 ...