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 ...
随机推荐
- 下拉框选择blur与click冲突问题
缘由:今天在做下拉框选择时,遇到click和blur冲突问题:具体现象如下 1.intput框获取焦点(focus事件)时显示隐藏的下拉框,失去焦点(blur事件)则隐藏下拉框 2.点击选择(clic ...
- 如何在同一台电脑上启动多个Tomcat服务器
安装第二个tomcat完成后,到安装目录下的conf子目录中打开server.xml文件,查找以下三处: (1)修改http范围端口(默认为8080端口) <Connector port=&qu ...
- 解决在ubuntu上启动的django项目在windows进行访问无法访问的问题
windows想要访问VMware中Ubuntu Server中Debug模式下的django服务,需要设置django允许非本机ip访问. 设置方法:1.查看虚拟机ip(建议VMware中设置Ubu ...
- git学习之时光穿梭机
"x"修改readme.txt文件,改成如下内容: Git is a distributed version control system. Git is free softwar ...
- 最新版XCoder 的使用方法
1.项目中,新建一个类库.名字随意,我取名:XCoder 2.右键 > 管理nuget程序包:搜索 XCode 并安装 3.在项目中新建:data.project.xml 的xml文件,并写入数 ...
- Python-待
内置函数总结 https://www.cnblogs.com/jason-lv/p/8243141.html https://www.cnblogs.com/pyyu/p/6702896.html 数 ...
- c++入门之字符相关入门
先上代码: # include "iostream" # include "string" //# define BYTE char//注意,这里没有分号,且# ...
- 助教总结 -【福大软工实践-2017-2018-K班】
助教总结 -[福大软工实践-2017-2018-K班] 非常抱歉这么晚才来写总结! 助教工作 助教共发表博客39篇. 助教共点评约500条. 起步 对于常规课程的起步,通常都是在第一次课堂上由老师对课 ...
- 单列模式,装饰器、new方法、类/静态方法实现单列模式
一.单列模式 单例模式(Singleton Pattern)是一种常用的软件设计模式,该模式的主要目的是确保某一个类只有一个实例存在. 如,某个服务器程序的配置信息存放在一个文件中,客户端通过一个 C ...
- @SuppressWarnings("resource")
Suppress 抑制:镇压:废止 Warnings警告 @SuppressWarnings("resource")是J2SE 提供的一个批注.该批注的作用是给编译器一条指令,告 ...