scu oj 4437: Carries (2015年四川省程序ACM设计竞赛B题目 )
来源:互联网 发布:115网盘淘宝怎么搜 编辑:程序博客网 时间:2024/04/29 08:04
其实这题只要想到这个结论就简单了。如果2个数a,b的第k位相加要进位,那么必须满足(a%10^k+b%10^k)>=10^k .有了这个结论就很简单了,枚举没一位就好了。
#include<stdio.h>#include<string.h>#include<iostream>#include<string>#include<queue>#include<cmath>#include<map>#include<algorithm>#include<vector>#include<bitset>using namespace std;const int mmax = 100010;typedef long long LL;int a[mmax];int b[mmax];int main(){ int n; while(~scanf("%d",&n)) { for(int i=0;i<n;i++) scanf("%d",&a[i]); int tmp=1; LL ans=0; for(int i=0;i<9;i++) { tmp*=10; for(int j=0;j<n;j++) b[j]=a[j]%tmp; sort(b,b+n); int r=n; for(int j=0;j<n;j++) { while( r && b[j]+b[r-1]>=tmp) r--; if(r<=j) ans+=(n-r-1); else ans+=(n-r); } } ans/=2; printf("%lld\n",ans); } return 0;}
1 0
- scu oj 4437: Carries (2015年四川省程序ACM设计竞赛B题目 )
- scu oj 4439 : Vertex Cover(2015年四川省程序ACM设计竞赛D题 )
- scu oj 4439 : Vertex Cover(2015年四川省程序ACM设计竞赛D题 )
- scu oj 4442 Party(2015年四川省acm程序设计竞赛)
- SCU 4437 Carries (2015四川省省赛B题)
- scu oj 4442 Party(2015年四川省acm程序设计竞赛)(*)
- scu oj 4442 Party(2015年四川省acm程序设计竞赛)★ ★ ★
- scu oj 4437: Carries
- scu oj 4443 Range Query (source :2015年四川省acm省赛)(*)
- scu oj 4443 Range Query (scoure :2015年四川省acm省赛)
- 2015 四川省赛 B Carries (脑洞题)
- 2015 四川省赛 B. Carries
- scu oj 4441 Necklace 2015年四川省赛F题(dp+数据结构)
- scu oj 4445 Right turn 2015年四川省赛J题(模拟题)
- 2015四川省赛 scu oj 4438 Censor
- [SCU 4437 Carries] 二分
- SCU 4437Carries(数论)
- 【思维】SCU 4437 Carries
- 字符串中最长回文字符串
- JSON Example With RESTEasy + Jackson
- 拓扑排序
- Android 中 有趣味的GridView
- ios 学习笔记<二> 【经典】
- scu oj 4437: Carries (2015年四川省程序ACM设计竞赛B题目 )
- 精确监听 Android ListView 滑动到底部
- 从KPCR中获取内核基地址
- rmi spring
- programming-challenges Erdös Numbers (110206) 题解
- CSS带箭头的DIV方框,自适应高度
- 【SuperMap .Net 组件】投影坐标与大地坐标转换
- android.graphics.Camera实现图像的旋转、缩放
- rmi接口连接失败