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 ...
随机推荐
- Qt文本读写之一:输入输出设备和文件操作
一.输入输出设备 QIODevice类是Qt中所有I/O设备的基础接口类,为诸如QFile.QBuffer和 QTcpSocket等支持读/写数据块的设备提供了一个抽象接口.QIODevice类是抽象 ...
- 【模板】c++动态数组vector
相信大家都知道$C$++里有一个流弊的$STL$模板库.. 今天我们就要谈一谈这里面的一个容器:动态数组$vector$. $vector$实际上类似于$a[]$这个东西,也就是说它重载了$[]$运算 ...
- Hibernate的一级缓存:快照区
参考来源:http://blog.sina.com.cn/s/blog_981ee5d80102w85f.html
- 关于spring mvc 和struts2的描述与对比
链接:https://www.nowcoder.com/questionTerminal/cf803beb7e3346caa636e4eaa3a8c2e9来源:牛客网 ---------------- ...
- Linux常用命令——tac、bc
1.从文件尾到文件头一页一页的显示内容 tac xxx.log |more //tac命令与cat命令相反,从文件尾开始读文件 2.shell下科学计算工具bc echo "scale=5; ...
- 【ADO.NET】 使用通用数据库操作类Database (SQL Server)
一.Web.config配置 <connectionStrings> <add name="constr_name" connectionString=" ...
- js深拷贝与浅拷贝的区别及实现
1. 对于基本数据类型 其值在内存中占据着固定大小的空间,并被保存在栈内存中.当一个变量向另一个变量复制基本类型的值,会创建这个值的副本,并且我们不能给基本数据类型的值添加属性.其为深拷贝. 2. 对 ...
- ES6学习笔记(9)----Symbol
参考书<ECMAScript 6入门>http://es6.ruanyifeng.com/ Symbol1.symbol:Symbol是javascript的第七种原始数据类型,代表独一无 ...
- 使用laravel的Command实现搜索引擎索引和模板的建立
创建command,初始化es 创建成功后,可通过php artisan 查看到 php artisan make:command ESInit 安装guzzle composer require g ...
- Quartz使用一 通过getJobDataMap传递数据
Quartz定时器使用比较广泛,介绍一点简单的使用 上代码:定义一个Job,执行具体的任务 package org.tonny.quartz; import java.text.SimpleDateF ...