Carries
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

  • 题意:给你n个数,求这n个数中任意两个数间想加进位了多少次
  • 题解:直接把这n个数除以10k10^k10k,然后把这n个数排下序,最后在这n个数中找满足相加>10k10^k10k的对数.k从1到9遍历一遍
#include<bits/stdc++.h>
#define mk make_pair
#define endl '\n'
#define pb pusk_back
#define _ ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
const double EPS = 1e-10;
const double PI = acos(-1);
bool SUBMIT = 1;
const int inf = 1e5+10;
int a[inf],b[inf];
int main()
{if(!SUBMIT)freopen("i.txt","r",stdin);else _;    int n;while(cin>>n){for(int i=0;i<n;i++)cin>>a[i];ll ans=0,m=1;for(int i=0;i<9;i++){m*=10;for(int j=0;j<n;j++)b[j]=a[j]%m;sort(b,b+n);int t=0;for(int j=n-1;j>=0;j--){for(;t<j;t++){if(b[t]+b[j]>=m){//cout<<"----"<<endl;ans+=j-t;break;}}}}cout<<ans<<endl;}return 0;
}

B - Carries SCU - 4437相关推荐

  1. 【思维】SCU 4437 Carries

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

  2. SCU - 4437 Carries

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

  3. SCU 4437 Carries 想法题

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

  4. 在ZC702上运行Linux(4)-编译和使用U-Boot Linux

    1. 安装工具链 参考http://wiki.xilinx.com/zynq-tools 下载并安装cross compiler.cross compiler位于http://www.xilinx.c ...

  5. 英语中的动词(基础篇)

    动 词 的 定 义: 动词是表示动作或状态的词. 例如: work,工作 , study,学习,eat 吃. 动词的分类:动词有两种分类方法. 1) 限定动词和非限定动词. 限定动词在句中作谓语,有人 ...

  6. 经济学python值得学吗_地藏经注音,地藏经全文,地藏经全文(注音版)——学佛网...

    地藏经专题部: 微信分享 地藏经全文(注音版) 地藏经全文(注音版) 恭请南无大慈大悲地藏王菩萨慈悲护持 赞 稽首本然净心地 无尽佛藏大慈尊 南方世界涌香云 香雨花云及花雨 宝雨宝云无数种 为祥为瑞遍 ...

  7. 【安价】亚拉奈夫想要复兴贫弱男爵家的样子【内政】2

    亚拉奈夫想要复兴贫弱男爵家的样子2 2015/07/09(木) 1321 : ◆PnL1XcUOPU:2012/06/16(土) 23:55:37 ID:GiMP3jms0 ▼―――――――――――― ...

  8. 《失业七个月,面试六十家公司》的深圳体验

    <失业七个月,面试六十家公司>的深圳体验 作者:色里调情 <失业a 七个月,面试六十家公司>的深圳体验 首先,坦白的讲,如果我现在不是找到了一份还合适的工作,我是根本不愿意 ...

  9. 【翻译】和麻美学姐一起的世界树(マミさんと世界樹スレ)第二话

    原作:やる夫版II ♦GzRLPVAnpk 原NETA:世界树迷宫2 诸王的圣杯 原帖Part1地址:http://jbbs.shitaraba.net/otaku/12973/storage/129 ...

最新文章

  1. 使用VScode开发C语言程序,环境安装配置,保姆级教程
  2. looper message handler之间的关系
  3. java号段_JAVA手机号正则(多号段)
  4. 直播丨国产数据库的机遇与挑战
  5. HTML中常见问题汇总贴
  6. UTF-8的CSV文件中文乱码问题解决办法
  7. FPV穿越机飞行入门练习
  8. Leet Code OJ 刷题顺序参考
  9. Explain的解读
  10. Matlab绘图保存为.fig格式以使用,及.fig文件的加载与数据读取
  11. MFC ShowWindow参数
  12. CRM笔记(1):对CRM概念的理解
  13. MATLAB-网页访问与关闭
  14. Linux3.x——USB Gadget HID keyboard + Mass storage
  15. 基于python的QQ第三方登陆实现工具类
  16. 周鸿袆:从程序员创业谈起
  17. Shortcut(二维平面内点的连续性)
  18. 认识web和web标准
  19. UE4 正式打包之PC端exe 常用设置(基础版)
  20. 综合布线缆线的敷设要求

热门文章

  1. c#NAudio 录音功能实现
  2. 腾讯游戏助手运行闪退日志查看
  3. data whale_data_analysis_task2_数据可视化
  4. 网民热议:顺丰菜鸟之争凸显大数据巨大商业价值
  5. swagger2 使用教程
  6. 技术总监/技术leader 职责与工作记录 第一天
  7. 上海有牛逼的互联网公司 薪资待遇汇总
  8. PI实时数据库接口技术的应用
  9. 计算机硬盘盒,避免踩坑,如何挑选适合自己电脑的硬盘盒?
  10. 批量分析中通快运单号物流,并查看是否签收