您当前的位置: 首页 > 

HeartFireY

暂无认证

  • 5浏览

    0关注

    334博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Educational Codeforces Round 118 div.2 ABC

HeartFireY 发布时间:2021-12-02 14:30:55 ,浏览量:5

A.Long Comparison

题目大意:给定两个数字 x 1 , x 2 x_1, x_2 x1​,x2​,以及参数 p 1 , p 2 p_1,p_2 p1​,p2​,表示在 x 1 , x 2 x_1,x_2 x1​,x2​后面加上 p 1 , p 2 p1_,p_2 p1,​p2​个 0 0 0。然后比较 a a a和 b b b的大小.

思路分析:首先统一数位,将两个数字化为相同位数的数字,然后根据后缀( 1 0 ( p 2 − p 1 ) 10^{(p_2 - p_1)} 10(p2​−p1​))分类讨论即可。

#include 
#define int long long
using namespace std;


int get(int num, int cnt = 0){
    while(num) cnt += 1, num /= 10;
    return cnt;
}

inline void solve(){
    int x1, p1; cin >> x1 >> p1;
    int x2, p2; cin >> x2 >> p2;
    int xp1 = get(x1), xp2 = get(x2);
    if(xp1 > xp2) while(xp1 - xp2) xp1--, x2 *= 10, p2--;
    if(xp2 > xp1) while(xp2 - xp1) xp2--, x1 *= 10, p1--;
    int det = p2 - p1;
    if(x1 > x2) puts((det > t;
    while(t--) solve();

    return 0;
}
B.Absent Remainder

题目大意:给定序列 { a 1 , a 2 , … , a n } \{a_1, a_2, \dots, a_n\} {a1​,a2​,…,an​},序列内元素各不相同。要求构造 ⌊ n 2 ⌋ \lfloor \frac{n}{2} \rfloor ⌊2n​⌋对 ( x , y ) (x, y) (x,y),满足 x ≠ y   ∩   x m o d    y ∉ { a i } x \neq y\ \cap\ x \mod y \notin \{a_i\} x​=y ∩ xmody∈/​{ai​}。

找到序列的最小值作为 y y y,然后找 ⌊ n 2 ⌋ \lfloor \frac{n}{2} \rfloor ⌊2n​⌋对元素作为 x x x即可。容易知道 a i m o d    a m i n n < a m i n n a_i \mod a_{minn} < a_{minn} ai​modaminn​> n; for(int i = 1; i > a[i]; sort(a + 1, a + 1 + n); for(int i = 1; i

关注
打赏
1662600635
查看更多评论
立即登录/注册

微信扫码登录

0.0957s