Educational Codeforces Round 50 (Rated for Div. 2)的A、B、C三题AC代码
A题链接:https://codeforces.com/contest/1036/problem/A
A题AC代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <malloc.h>
#include <stdbool.h>
#include <ctype.h> typedef long long ll; int main()
{
ll n, k, i, j, ans;
while( ~scanf( "%I64d%I64d", &n, &k ) )
{
printf( "%I64d\n", ( k + n - ) / n );
}
return ;
}
B题链接:https://codeforces.com/contest/1036/problem/B
B题AC代码:
#include <iostream>
#include <cstring>
#include <cstdio> typedef unsigned long long ULL;
typedef const int cint;
typedef long long LL;
using namespace std; int q;
LL n,m,k;
template< typename Q >
void inin(Q &); int main()
{
inin(q);
while( q -- )
{
inin(n);
inin(m);
inin(k);
if( n > m )
swap( n, m );
if( k < m )
printf( "-1" );
else
{
if( n == m )
{
if( ( k-n ) & )
printf( "%I64d", k - );
else
printf( "%I64d", k );
}
else
{
LL temp = m - n;
if( temp & )
printf( "%I64d", k - );
else
{
if( ( k - m ) & )
printf( "%I64d", k - );
else
printf( "%I64d", k );
}
}
}
printf( "\n" );
}
return ;
} template< typename Q >
void inin( Q &x )
{
x=;
int f=;
char ch;
scanf( "%c", &ch );
while( ch < '' || ch > '' )
{
if( ch == '-' )
f = ;
scanf( "%c", &ch );
}
while( ch >= '' && ch <= '' )
{
x = x* + ch - '';
scanf( "%c", &ch );
}
x = f?-x:x;
}
C题链接:https://codeforces.com/contest/1036/problem/C
C题AC代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <malloc.h>
#include <stdbool.h>
#include <ctype.h> typedef long long ll; ll Arr[][];
int dig[];
ll dp( int, int, int );
ll calc(ll); int main()
{
memset( Arr, -, sizeof(Arr) );
int i, T=;
ll L,R;
while( ~scanf( "%d", &T ) )
{
for ( i = ; i <= T; i ++ )
{
scanf( "%I64d%I64d", &L, &R );
L--;
printf( "%I64d\n", calc(R) - calc(L) );
}
}
return ;
} ll dp( int len, int res, int lim )
{
if ( res > )
return ;
if ( len == )
return ;
if ( !lim && Arr[len][res] > )
return Arr[len][res];
ll ret = ;
int up = ;
if (lim)
up=dig[len];
int i;
for ( i = ; i <= up; i ++ )
ret += dp( len-, res+(i>), lim && ( i == up ) );
if (!lim) Arr[len][res]=ret;
return ret;
} ll calc(ll x)
{
int _sum = ;
while (x)
{
dig[ ++ _sum ] = x % ;
x /= ;
}
return dp( _sum, , );
}
全部测过样例再提交,另外,本蒟蒻还从未做过D……

Educational Codeforces Round 50 (Rated for Div. 2)的A、B、C三题AC代码的更多相关文章
- Educational Codeforces Round 50 (Rated for Div. 2) F - Relatively Prime Powers(数学+容斥)
题目链接:http://codeforces.com/contest/1036/problem/F 题意: 题解:求在[2,n]中,x != a ^ b(b >= 2 即为gcd)的个数,那么实 ...
- Educational Codeforces Round 50 (Rated for Div. 2) C. Classy Numbers
C. Classy Numbers 题目链接:https://codeforces.com/contest/1036/problem/C 题意: 给出n个询问,每个询问给出Li,Ri,问在这个闭区间中 ...
- Educational Codeforces Round 50 (Rated for Div. 2)F. Relatively Prime Powers
实际上就是求在[2,n]中,x != a^b的个数,那么实际上就是要求x=a^b的个数,然后用总数减掉就好了. 直接开方求和显然会有重复的数.容斥搞一下,但实际上是要用到莫比乌斯函数的,另外要注意减掉 ...
- Educational Codeforces Round 50 (Rated for Div. 2) E. Covered Points
注释上都有解析了,就不写了吧,去重的问题就用set解决,并且呢第i个线段最多和其他线段产生i-1个交点,n^2logn. #include <cmath> #include <cst ...
- Educational Codeforces Round 76 (Rated for Div. 2) A. Two Rival Students 水题
A. Two Rival Students There are
- Educational Codeforces Round 94 (Rated for Div. 2) A. String Similarity (构造水题)
题意:给你一个长度为\(2*n-1\)的字符串\(s\),让你构造一个长度为\(n\)的字符串,使得构造的字符串中有相同位置的字符等于\(s[1..n],s[2..n+1],...,s[n,2n-1] ...
- Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...
- Educational Codeforces Round 63 (Rated for Div. 2) 题解
Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
随机推荐
- C++中virtual继承的深入理解
今天专门看了一下虚继承的东西,以前都没怎么用过,具体如下:父类: 复制代码代码如下: class CParent { .... }; 继承类的声明比较特别: class CChild : ...
- URAL 7077 Little Zu Chongzhi's Triangles(14广州I)
题目传送门 题意:有n根木棍,三根可能能够构成三角形,选出最多的三角形,问最大面积 分析:看到这个数据范围应该想到状压DP,这次我想到了.0010101的状态中,1表示第i根木棍选择,0表示没选,每一 ...
- javascript简单的表单验证
<html> <head> <title>用户登录</title> <script language="javascript" ...
- 域名IP主动验证(一)
功能:主动验证给定的域名.IP对是否真正的关联 思路: 1.一开始通过修改hosts文件,把待验证的域名.IP对添加到文件里,然后用wget尝试访问,再恢复hosts文件重新验证下一对 2.后来了解到 ...
- Vue 页面加载闪现代码问题
CSS中 [v-cloak] { display: none; } HTML中 <div v-cloak> {{ message }} </div> 显示代码主要是{{}}这个 ...
- C#中的委托(转)
C# 中的委托和事件 引言 委托 和 事件在 .Net Framework中的应用非常广泛,然而,较好地理解委托和事件对很多接触C#时间不长的人来说并不容易.它们就像是一道槛儿,过了这个槛的人,觉得真 ...
- [转]Java中实现自定义的注解处理器
Java中实现自定义的注解处理器(Annotation Processor) 置顶2016年07月25日 19:42:49 阅读数:9877 在之前的<简单实现ButterKnife的注解功能& ...
- 【学习笔记】比特(bit)、字,字节(B)存储单位之间的关系+其与操作系统位数的关系+不同编译器编译方式下数据类型的表示范围
1.在表示网络传输速度中与表示存储单位的不同: 表示存储单位时:1kB=1024B,但在网络中表示传输速度是1KB=1000B 2.下面介绍表示存储单位时的关系及其与操作系统位数的关系: 1B=8bi ...
- Android CursorAdapter的使用
CursorAdapter继承于BaseAdapter,为Cursor和ListView连接提供了桥梁. 首先看一下CursorAdapter的部分源码: /** * @see android.wid ...
- EEPROM介绍
EEPROM( Electrically Erasable Programmable Read Only Memory )全称是电气可擦除可编程只读存储器,是非易失存储器,可以访问到每个字节,容量比较 ...