题意:确定一个回文偶数十进制数字,输入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. centos 7 安装mqtt 修改用户名和密码

    我先新买个Centos 的系统 咱登录呢就用这个软件,主要是方便,可以少安装一些东西 根据自己的系统选择,上面的是32位的. 输入 root 回车 输入密码然后回车  输入的时候什么也不显示 输入 c ...

  2. JAVA生成一个二维数组,使中间元素不与相邻的9个元素相等,并限制每一个元素的个数

    JAVA生成一个二维数组,使中间元素不与相邻的9个元素相等,并限制每一个元素的个数 示例如下 至少需要九个元素:"A","B","C",&q ...

  3. 深入理解跨域SSO(单点登录)原理与技术

    一:SSO体系结构 SSO ​ SSO英文全称Single Sign On,单点登录.SSO是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统.它包括可以将这次主要的登录映射到其他 ...

  4. .NET开源项目 QuarkDoc 一款自带极简主义属性的文档管理系统

    有些话说在前头 因为公司产品业务重构且功能拆分组件化,往后会有很多的接口文档需要留存,所以急需一款文档管理系统.当时选型要求3点: 1.不能是云平台上的Saas服务,整个系统都要在自己公司部署维护(数 ...

  5. Dockerfile cnetos7_nginx1.15.10

    FROM centos:7 MAINTAINER yuyongxr yuyongxr@gmail.com LABEL Discription="centos7+nginx1.15.10&qu ...

  6. 学习用Node.js和Elasticsearch构建搜索引擎(1):了解并运行Elasticsearch

    1.学习Elasticsearch概述. 了解Elasticsearch是什么?能做什么?可以查一下elasticsearch.lucene等的相关介绍,另外也可以查查资料比较一下其它的搜索引擎sph ...

  7. Sampling Matrix

    这些天看了一些关于采样矩阵(大概是这么翻译的)的论文,简单做个总结. FAST MONTE CARLO ALGORITHMS FOR MATRICES I: APPROXIMATING MATRIX ...

  8. matplotlib 入门之Pyplot tutorial

    文章目录 pyplot 介绍 修饰你的图案 格式字符串 [color][marker][line] Colors Markers Line Styles 利用关键字作图(大概是数据映射到属性吧) 传入 ...

  9. 关于对于system函数和c++标准下的新的变量定义方式{}

  10. Two distinct points CodeForces - 1108A (签到)

    You are given two segments [l1;r1][l1;r1] and [l2;r2][l2;r2] on the xx-axis. It is guaranteed that l ...