题意:确定一个回文偶数十进制数字,输入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的更多相关文章

  1. Codeforces Round #449 (Div. 2)

    Codeforces Round #449 (Div. 2) https://codeforces.com/contest/897 A #include<bits/stdc++.h> us ...

  2. codeforces DIV2 D 最短路

    http://codeforces.com/contest/716/problem/D 题目大意:给你一些边,有权值,权值为0的表示目前该边不存在,但是可以把0修改成另外一个权值.现在,我们重新建路, ...

  3. codeforces div2 677 D

    http://codeforces.com/problemset/problem/677/D 题目大意: 给你一个n*m的图,上面有p种钥匙(p<=n*m),每种钥匙至少有一个,期初所有为1的钥 ...

  4. codeforces div2.C

    C. New Year and Rating time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  5. CF&&CC百套计划1 Codeforces Round #449 C. Willem, Chtholly and Seniorious (Old Driver Tree)

    http://codeforces.com/problemset/problem/896/C 题意: 对于一个随机序列,执行以下操作: 区间赋值 区间加 区间求第k小 区间求k次幂的和 对于随机序列, ...

  6. 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 最后填出一个单调非 ...

  7. 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> # ...

  8. Codeforces Round #449 (Div. 2)ABCD

    又掉分了0 0. A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input ...

  9. 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 ...

  10. 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 ...

随机推荐

  1. Generative Adversarial Nets[Pre-WGAN]

    本文来自<towards principled methods for training generative adversarial networks>,时间线为2017年1月,第一作者 ...

  2. [03] SpringBoot+MyBatis+Shiro搭建杂谈

    0.写在前面的话 一直想能仿公司框架的形式,着手做一个简单的脚手架,一来是带着目标性能更好地学习,接触新的技术,另外自己如果有什么想要实现的简单需求,就可以进行快速开发,主要还是希望能在权限上有所控制 ...

  3. Java核心数据结构(List,Map,Set)原理与使用技巧

    JDK提供了一组主要的数据结构实现,如List.Map.Set等常用数据结构.这些数据都继承自 java.util.Collection 接口,并位于 java.util 包内. 1.List接口 最 ...

  4. Java模拟登录带验证码的教务系统(原理详解)

    一:原理 客户端访问服务器,服务器通过Session对象记录会话,服务器可以指定一个唯一的session ID作为cookie来代表每个客户端,用来识别这个客户端接下来的请求. 我们通过Chrome浏 ...

  5. NetCore实践篇:分布式监控客户端ZipkinTracer从入门到放弃之路

    前言 本文紧接上篇.Net架构篇:思考如何设计一款实用的分布式监控系统?,上篇仅仅是个思考篇,跟本文没有太大的关系.但有思考,结合现有的开源组件,实践起来更易理解起来,所以看本文之前,应该先看下上篇博 ...

  6. .Net Core 在 Linux-Centos上的部署实战教程(三)

    绑定域名,利用Nginx反向代理来操作 1.安装Nginx yun install nginx 安装成功 2.启动nginx service nginx start 报报报错了~~·      运行 ...

  7. TRIO-basic指令--函数FUNCTION

    TRIO-basic支持函数(强类型)编程,与PLC来相比较的话类似于定义的功能块可以重复调用,和C,C#......等一些高级的编程语言的函数类似.上一次的demo中决定尝试TRIO的函数来做一些例 ...

  8. git更新提交代码常用命令

    git pull 拉取代码 git add -A 提交所有变化(包括删除.新增.修改) git commit -m "注释" 本地仓库提交 git push origin mast ...

  9. shell正则表达

    shell正则表达 .*和.?的比较: 比如说匹配输入串A: 101000000000100 使用 1.*1 将会匹配到1010000000001,匹配方法:先匹配至输入串A的最后, 然后向前匹配,直 ...

  10. javascript重定向页面并用post方法传递消息

    javascript中重定向页面得方法很多,同时能传递消息的也不少:但可用post方法传递的我只找到两种: 第一种方法:用document.write在 JavaScript函数中,用document ...