A. Sum of 2050
time limit per test1 second
memory limit per test256 megabytes

A number is called 2050-number if it is 2050, 20500, …, (2050⋅10k for integer k≥0).

Given a number n, you are asked to represent n as the sum of some (not necessarily distinct) 2050-numbers. Compute the minimum number of 2050-numbers required for that.

Input
The first line contains a single integer T (1≤T≤1000) denoting the number of test cases.

The only line of each test case contains a single integer n (1≤n≤1018) denoting the number to be represented.

Output
For each test case, output the minimum number of 2050-numbers in one line.

If n cannot be represented as the sum of 2050-numbers, output −1 instead.

Example
input
6
205
2050
4100
20500
22550
25308639900
output
-1
1
2
1
2
36

Note
In the third case, 4100=2050+2050.

In the fifth case, 22550=20500+2050.

问题链接:CodeForces - 1517A Sum of 2050
问题简述:(略)
问题分析:(略)
AC的C++语言程序如下:

/* CodeForces - 1517A Sum of 2050 */#include <bits/stdc++.h>using namespace std;const int M = 2050;int main()
{int t;scanf("%d", &t);while (t--) {long long n, ans = -1;scanf("%lld", &n);if (n % M == 0) {ans = 0;n /= M;while (n) {ans += n % 10;n /= 10;}}printf("%lld\n", ans);}return 0;
}```

CodeForces - 1517A Sum of 2050相关推荐

  1. codeforces 85D. Sum of Medians

    二次联通门 : codeforces 85D. Sum of Medians /*codeforces 85D. Sum of Medians正解线段树或是平衡树结果用vector暴力卡过去了 */ ...

  2. codeforces 85D. Sum of Medians(线段树or分块)

    题目链接:codeforces 85D. Sum of Medians 题意: add x 表示向集合中添加x(添加x的时候保证x是第一次被添加入集合) del x 表示从集合中删除x (删除x的时候 ...

  3. Codeforces 85D Sum of Medians(线段树)

    题目链接:Codeforces 85D - Sum of Medians 题目大意:N个操作,add x:向集合中添加x:del x:删除集合中的x:sum:将集合排序后,将集合中所有下标i % 5 ...

  4. Codeforces 847C - Sum of Nestings

    847C - Sum of Nestings 思路:简单的递归. 代码: #include<bits/stdc++.h> using namespace std; #define ll l ...

  5. Codeforces 85D Sum of Medians

    传送门 D. Sum of Medians time limit per test 3 seconds memory limit per test 256 megabytes input standa ...

  6. Codeforces 85D Sum of Medians[线段树]

    题意:给了一个set,有n个操作,有三种操作 1. add  x 把 x 放入set中: 2. del  x 把 x 从set中删去: 3. sum 求set中,第n大的数,n%5==3,的总和. 分 ...

  7. CodeForces 85D Sum of Medians Splay | 线段树

    Sum of Medians 题解: 对于这个题目,先想到是建立5棵Splay,然后每次更新把后面一段区间的树切下来,然后再转圈圈把切下来的树和别的树合并. 但是感觉写起来太麻烦就放弃了. 建立5棵线 ...

  8. codeforces E. Sum of Digits

    这题可以暴力打本地表...  等正解出来再搞正解 对于k=0 我们让9尽量多就行 这个可以特判 对于k=1 暴力打表到1e9 对于k>=2 暴力打表到1e6(发现1e6以上就没有变化了) 当然这 ...

  9. CodeForces - 1373E Sum of Digits(贪心)

    题目链接:点击查看 题目大意:设 f( x ) 为 x 的数位之和,给出一个 n 和一个 k ,求  的最小 x ,若不存在,输出 -1 题目分析:因为 n 和 k 比较小,所以可以打表,当 k 为 ...

最新文章

  1. JavaScript(六)函数
  2. python下什么-python要下什么
  3. FileInputStream、FileReader、FileWriter和File
  4. crontab命令简介
  5. DreamWeaver下如何应用CSS样式
  6. .net core 技术栈 网站收集
  7. 使用t-sql语句修改表中的某些数据及数据类型。_测试开发工程师数据库篇(一)...
  8. 用jQuery写的最简单的表单验证
  9. 如何做PHD (1)
  10. 手把手教你用C语言画“心”!
  11. tcpdump/editcap等工具保存文件时名称中自定义添加日期/时间
  12. u盘插入后计算机内没有选项,U盘插到电脑,无法读取,属性里面空间全是0是怎么回事?...
  13. Samba配置文件常用参数详解
  14. KS(Kolmogorov–Smirnov)模型区分能力指标
  15. 红蜘蛛多媒体网络教室v7.2版一款网络教学的软件
  16. 大唐凌烟阁开国廿四将
  17. ATEN CS22DP 2端口USB DisplayPort带线式KVM多电脑切换器 (外接式切换按键)
  18. [附源码]计算机毕业设计校园运动会管理系统Springboot程序
  19. Micropython进阶小实验 如何用单片机制作鞋码匹配仪
  20. linux下开启、关闭、重启mysql服务命令

热门文章

  1. 如何通过svg代码还原图片_如何通过nginx反向代理来调试代码?
  2. 使用GDAL对HDF数据进行校正
  3. Docker部署SpringCloud ELK+RabbitMQ日志
  4. 手机游戏行业洗牌在即 成本增长小团队出局
  5. Starling移动平台开发初体验
  6. 新手老问题---------跨线程的控件访问
  7. matlab兔子繁殖问题,斐波那契数列在《疯狂动物城》兔子繁衍中的应用
  8. 如何打开电脑就自动显示html文件,电脑教程:Win10怎么打开html文件
  9. 全量增量数据同步方法(Hive date_add date_sub)
  10. spark加载数据的方式