frog has n integers a1,a2,…,an, and she wants to add them pairwise.

Unfortunately, frog is somehow afraid of carries (进位). She defines hardness h(x,y) for adding x and y the number of carries involved in the calculation. For example, h(1,9)=1,h(1,99)=2.

Find the total hardness adding n integers pairwise. In another word, find
∑1≤i<j≤nh(ai,aj)
.

Input
The input consists of multiple tests. For each test:

The first line contains 1 integer n (2≤n≤105). The second line contains n integers a1,a2,…,an. (0≤ai≤109).

Output
For each test, write 1 integer which denotes the total hardness.

Sample Input
2
5 5
10
0 1 2 3 4 5 6 7 8 9
Sample Output
1
20

思路:

从个位开始找一直到最大的位置,看相加大于等于10的位数平方,num就加上后面未加上的数有几个就加几。

代码:

#include<iostream>
#include <ostream>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<string>
#include<cmath>
#define ll long long
#define dd double
#define mes(x,y) memset(x,y,sizeof(y))
using namespace std;
int a[100010],b[100010];
int main(){int n;while(cin>>n){for(int i=0;i<n;i++)cin>>a[i];ll v=1,num=0;for(int i=0;i<9;i++){v*=10;for(int j=0;j<n;j++)b[j]=a[j]%v;sort(b,b+n);int l=0; for(int j=n-1;j>=0;j--){for(;l<j;l++){if(b[j]+b[l]>=v){num+=j-l;break;}}}}cout<<num<<endl;}
}

SCU - 4437 Carries相关推荐

  1. 【思维】SCU 4437 Carries

    4437: Carries Submit your solution     Discuss this problem     Best solutions Carries frog has nn i ...

  2. SCU 4437 Carries 想法题

    题目大意: 就是现在给出10万个1e9以内的非负整数, 问他们两两相加一共会有多少次进位(10进制加法), 例如99 + 1有2次进位, 10 + 19没有进位 大致思路: 其实就是一个简单题, 比赛 ...

  3. B - Carries SCU - 4437

    Carries frog has n integers a1,a2,-,an, and she wants to add them pairwise. Unfortunately, frog is s ...

  4. 二分 + 模拟 - Carries

    Carries Problem's Link Mean: 给你n个数,让你计算这n个数两两组合相加的和进位的次数. analyse: 脑洞题. 首先要知道:对于两个数的第k位相加会进位的条件是:a%( ...

  5. Zynq7000术语PL,PS,APU,SCU介绍

    Zynq7000术语详解,不懂啥是PL,PS,APU,SCU?那就进来看看吧   相信大家刚看到Zynq手册的时候,对着那么一大堆缩略语肯定是一头雾水,特转来一篇文章,为大家解惑 摘要:本文介绍与XI ...

  6. GDCM:SCU功能的测试程序

    GDCM:SCU功能的测试程序 GDCM:SCU功能的测试程序 GDCM:SCU功能的测试程序 #include "gdcmCompositeNetworkFunctions.h" ...

  7. HDU 4588 Count The Carries 数学

    Count The Carries Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest ...

  8. 【转】用fo-dicom实现print scu的注意事项!!!!!!!!!

    转自:https://blog.csdn.net/tvsofa2008/article/details/50245357 用fo-dicom实现print scu的注意事项 fo-dicom是一个开源 ...

  9. 从入门到入土:python爬虫|SCU每日打卡自动填写|测试训练|

    此博客仅用于记录个人学习进度,学识浅薄,若有错误观点欢迎评论区指出.欢迎各位前来交流.(部分材料来源网络,若有侵权,立即删除) 本人博客所有文章纯属学习之用,不涉及商业利益.不合适引用,自当删除! 若 ...

最新文章

  1. 嵌入式系统笔记之自动登录
  2. 【Groovy】编译时元编程 ( ASTTransformation#visit 方法获取 Groovy 源文件 )
  3. UBUNTU安装 Rabbitvsc可视化版本控制客户端软件
  4. 牛客题霸 NC15 求二叉树的层序遍历
  5. http://acm.zzuli.edu.cn/zzuliacm/problem.php?id=1895 二分
  6. sql自动审核工具-inception
  7. 成功的MES项目,前期都做了些什么?
  8. 近一周学习之-----npm换源工具之nrm
  9. linux的yum命令无法使用在哪里下载_Centos Linux下载rpm软件包(基础环境篇)-从零到无 - 飞翔的小胖猪...
  10. C/C++网络编程详解(Windows版)
  11. 数据结构计算机复试题,2021考研计算机408数据结构试题及答案解析
  12. 2021年PayPal要如何绑定到国内?
  13. 中国工具类App折戟海外,为什么只有猎豹移动杀出血路?
  14. 第十三章:(1)CompletableFuture异步回调
  15. 对给定的10个国家名,按其字母的顺序输出。C++
  16. Andriod studio manifast中添加权限却还无效日历api设置定时闹钟却不生效
  17. php使用ElasticSearch
  18. kali_vps,debian,Ubuntu下搭建LAMP环境
  19. java笔记——反射
  20. numpy ndarray嵌套ndarray浅显理解

热门文章

  1. 用友增资致远1200万 国内最大OA厂商发布新品
  2. Simulink根据魔术公式建立轮胎模型
  3. 在一个excel里面直接批量从谷歌地图抓取经纬度(vba部分)
  4. 看了《流浪地球2》海报,我想教你用PPT说浪漫情话!
  5. caused by java.io.io_疑难杂症之 Error:java.io.InvalidClassException
  6. Java获取当前时间前24小时时间
  7. oracle怎样修改口令,修改Oracle数据库sys口令
  8. S905/S905M安装LAKKA教程
  9. 传音控股以科技立品牌,2021一季度净利大增125.93%
  10. 每日一道 LeetCode (36):相交链表