codeforces-div2-449-B
题意:确定一个回文偶数十进制数字,输入k和q,求前k小的和对q取余的值
解题思路:首先确定一个,第k个回文偶数一定前半段一定是k,比如第12个,这个数就是1221;
代码:
#include<iostream>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
int main()
{
ll k,q;
ll sum;
ll temp;
ll x1;
ll x2;
int a[15];
int cnt;
cin>>k>>q; sum=0;
while(k!=0)
{
cnt=0;
temp=0;
int m=k;
while(m)
{
a[++cnt]=m%10;
m=m/10;
}
x1=1;x2=1;
for(int i=1;i<=cnt;i++)
x2=x2*10;
//cout<<x2<<endl;
for(int i=cnt;i>=1;i--)
{
temp+=x1*a[i];
x1*=10;
}
// cout<<temp<<endl;
for(int i=1;i<=cnt;i++)
{
temp+=x2*a[i];
x2*=10;
}
//cout<<temp<<endl;
temp=temp%q;
sum+=temp;
sum=sum%q;
k--;
}
cout<<sum<<endl;
return 0;
}
codeforces-div2-449-B的更多相关文章
- Codeforces Round #449 (Div. 2)
Codeforces Round #449 (Div. 2) https://codeforces.com/contest/897 A #include<bits/stdc++.h> us ...
- codeforces DIV2 D 最短路
http://codeforces.com/contest/716/problem/D 题目大意:给你一些边,有权值,权值为0的表示目前该边不存在,但是可以把0修改成另外一个权值.现在,我们重新建路, ...
- codeforces div2 677 D
http://codeforces.com/problemset/problem/677/D 题目大意: 给你一个n*m的图,上面有p种钥匙(p<=n*m),每种钥匙至少有一个,期初所有为1的钥 ...
- codeforces div2.C
C. New Year and Rating time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- CF&&CC百套计划1 Codeforces Round #449 C. Willem, Chtholly and Seniorious (Old Driver Tree)
http://codeforces.com/problemset/problem/896/C 题意: 对于一个随机序列,执行以下操作: 区间赋值 区间加 区间求第k小 区间求k次幂的和 对于随机序列, ...
- CF&&CC百套计划1 Codeforces Round #449 B. Ithea Plays With Chtholly
http://codeforces.com/contest/896/problem/B 题意: 交互题 n张卡片填m个1到c之间的数,1<=n*ceil(c/2)<=m 最后填出一个单调非 ...
- CF&&CC百套计划1 Codeforces Round #449 A. Nephren gives a riddle
http://codeforces.com/contest/896/problem/A 第i个字符串嵌套第i-1个字符串 求第n个字符串的第k个字母 dfs #include<map> # ...
- Codeforces Round #449 (Div. 2)ABCD
又掉分了0 0. A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input ...
- Codeforces Round #449 (Div. 2) B. Chtholly's request【偶数位回文数】
B. Chtholly's request time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Codeforces Round #449 [ C/A. Nephren gives a riddle ] [ D/B. Ithea Plays With Chtholly ]
PROBLEM C/A. Nephren gives a riddle 题 http://codeforces.com/contest/896/problem/A codeforces 896a 89 ...
随机推荐
- 对称与非对称加密;SSL;HTTPS;AJP
1.对称加密就是加密与解密的时候都是用一个密码 2.非对称加密,有一对密码A,B:用A加密就得用B解密,相对的用B加密就得用A解密 3.公钥与私钥,这一对密码,随便拿一个公布出去,那个就是公钥,剩下一 ...
- C# 多线程及同步简介示例
60年代,在OS中能拥有资源和独立运行的基本单位是进程,然而随着计算机技术的发展,进程出现了很多弊端,一是由于进程是资源拥有者,创建.撤消与切换存在较大的时空开销,因此需要引入轻型进程: ...
- 史上最全面的Elasticsearch使用指南
Elasticsearch使用指南 Elasticsearch使用指南 前言 ES是什么 什么是全文检索 ES的应用场景 ES的存储结构 第一章:安装 1.下载 2.解压 3.配置 4.启动 5.查看 ...
- babel-polyfill使用与性能优化
文章首发于笔者的个人博客 文章概览 本文主要内容包括:什么是babel-polyfill,如何使用,如何通过按需加载进行性能优化. 本文所有例子可以在 笔者的github 找到. 什么是babel-p ...
- navicat 和 pymysql
---------------------------------------------------相信时间的力量,单每月经过努力的时间,一切的安排都是懊脑的安排. # # ------------ ...
- docker容器与宿主交互数据
1.查看容器 [root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES cd6957191 ...
- Can’t connect to local MySQL server through socket 原因解析
在连接mysql的时,经常会出现以下错误提示: ERROR (HY000): Can't connect to local MySQL server through socket '/var/lib/ ...
- Python-模块导入-63
模块导入: # 内置模块 # 扩展的 django # 自定义的 # 文件 # import demo # def read(): # print('my read func') # demo.rea ...
- Python_老男孩练习题1
get有陷阱:value 5.以下打印的内容是:—————— —————— —————— [10, 'a'] [123] [10, 'a'] #方法一: 将list 转为 set #l ...
- H5 70-清除浮动方式五
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...