Problem A. Mischievous Problem Setter

签到.

 #include <bits/stdc++.h>
using namespace std; #define ll long long
#define N 100010
#define pii pair <int, int>
#define x first
#define y second
int t, n, m;
pii a[N]; int main()
{
scanf("%d", &t);
for (int kase = ; kase <= t; ++kase)
{
printf("Case %d: ", kase);
scanf("%d%d", &n, &m);
for (int i = ; i <= n; ++i) scanf("%d", &a[i].x);
for (int i = ; i <= n; ++i) scanf("%d", &a[i].y);
sort(a + , a + + n);
int res = ;
for (int i = ; i <= n; ++i)
{
if (a[i].y <= m)
{
++res;
m -= a[i].y;
}
else
break;
}
printf("%d\n", res);
}
return ;
}

Problem K. Mr. Panda and Kakin

题意:

RSA解密

思路:

注意到题目的本意是求$x^(2^{30} + 3) = c \pmod (n)$

$从根号处暴力破出p和q,然后求(2^{30} + 3)对 \phi(n) = (p - 1) \cdot (q - 1) 的逆$

$最后求幂即可,但是注意到大数模乘会爆,所以可以long \;double 或者用中国剩余定理$

 #include <bits/stdc++.h>
using namespace std; #define ll long long
int t;
ll p, q; ll qmod(ll base, ll n, ll MOD)
{
base %= MOD;
ll res = ;
while (n)
{
if (n & ) res = res * base % MOD;
base = base * base % MOD;
n >>= ;
}
return res;
} void get(ll n)
{
for (ll i = sqrt(n); i >= ; --i) if (n % i == )
{
p = i;
q = n / i;
return;
}
} ll exgcd(ll a, ll b, ll &x, ll &y)
{
if (a == && b == ) return -;
if (b == ) { x = , y = ; return a; }
ll d = exgcd(b, a % b, y, x);
y -= a / b * x;
return d;
} ll mod_reverse(ll a, ll n)
{
ll x, y;
ll d = exgcd(a, n, x, y);
if (d == ) return (x % n + n) % n;
else return -;
} int main()
{
ll n, c;
scanf("%d", &t);
for (int kase = ; kase <= t; ++kase)
{
printf("Case %d: ", kase);
scanf("%lld%lld", &n, &c);
get(n);
ll r = (p - ) * (q - );
ll u = mod_reverse(((1ll << ) + ), r);
ll a = qmod(c, u, p);
ll b = qmod(c, u, q);
b = (b - a + q) % q;
ll inv = qmod(p, q - , q);
ll res = b * inv % q;
res = (res * p % n + a) % n;
printf("%lld\n", res);
}
return ;
}

2018 China Collegiate Programming Contest Final (CCPC-Final 2018)的更多相关文章

  1. 2018 China Collegiate Programming Contest Final (CCPC-Final 2018)-K - Mr. Panda and Kakin-中国剩余定理+同余定理

    2018 China Collegiate Programming Contest Final (CCPC-Final 2018)-K - Mr. Panda and Kakin-中国剩余定理+同余定 ...

  2. 模拟赛小结:2018 China Collegiate Programming Contest Final (CCPC-Final 2018)

    比赛链接:传送门 跌跌撞撞6题摸银. 封榜后两题,把手上的题做完了还算舒服.就是罚时有点高. 开出了一道奇奇怪怪的题(K),然后ccpcf银应该比区域赛银要难吧,反正很开心qwq. Problem A ...

  3. 2018 China Collegiate Programming Contest Final (CCPC-Final 2018)(A B G I L)

    A:签到题,正常模拟即可. #include<bits/stdc++.h> using namespace std; ; struct node{ int id, time; }; nod ...

  4. 2016 China Collegiate Programming Contest Final

    2016 China Collegiate Programming Contest Final Table of Contents 2016 China Collegiate Programming ...

  5. The 2015 China Collegiate Programming Contest A. Secrete Master Plan hdu5540

    Secrete Master Plan Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Othe ...

  6. The 2015 China Collegiate Programming Contest Game Rooms

    Game Rooms Time Limit: 4000/4000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submi ...

  7. 2018 German Collegiate Programming Contest (GCPC 18)

    2018 German Collegiate Programming Contest (GCPC 18) Attack on Alpha-Zet 建树,求lca 代码: #include <al ...

  8. (寒假GYM开黑)2018 German Collegiate Programming Contest (GCPC 18)

    layout: post title: 2018 German Collegiate Programming Contest (GCPC 18) author: "luowentaoaa&q ...

  9. 2017 China Collegiate Programming Contest Final (CCPC 2017)

    题解右转队伍wiki https://acm.ecnu.edu.cn/wiki/index.php?title=2017_China_Collegiate_Programming_Contest_Fi ...

随机推荐

  1. Python 循环退出

    常用语句: break :退出整个循环,循环外的语句继续执行continue :退出本次循环,继续下一次循环pass :什么也不做,相当于在这里占个位置,以便以后修改代码sys.exit() :直接退 ...

  2. js遍历商品编码

    function bathAuditGoods(state) { var selections = $("#deliveryGrid").datagrid('getSelectio ...

  3. mybatis 循环遍历

    /****Service/ public ServiceMessage<MemberFreedomRepModel> getMFListByPay(Long memberId,Long f ...

  4. android中必备的接口回调用法

    1 ,这个方法很常见,本人觉得也很实用,分享下吧 public class DirverDistanceTool { public void getDirverDistance(LatLng star ...

  5. block基本使用和底层

    block基础使用语法   一.block与函数的对比 定义函数指针 int (*myFn)(); 定义Blocks int (^MyBlocks)(int,int); 调用函数指针 (*myFn)( ...

  6. 解决提示“配色方案已更改为Windows7 Basic”

    WIN7是很多用户都用过的系统,是由微软推出的.下面就说一个小技巧. 如何解决Win7系统提示:“配色方案已更改为Windows 7 Basic”解决方案.   更改Win7配色方案 首先,右击桌面空 ...

  7. 网络虚拟化技术(一): Linux网络虚拟化

    创建虚拟网络环境 使用命令 $ ip netns add net0 可以创建一个完全隔离的新网络环境,这个环境包括一个独立的网卡空间,路由表,ARP表,ip地址表,iptables,ebtables, ...

  8. 微信小游戏 egret.getDefinitionByName获取不到

    使用getDefinitionByName获取类定义 输出为null,获取不了 增加window["LoadingUI"] = LoadingUI 获取成功 总结: 这样无论是游戏 ...

  9. 把 Activity 改成 ListActivity继续使用 setContentView

    ListActivity has a default layout that consists of a single, full-screen list in the center of the s ...

  10. MyBatis中typealiases的使用

    转自:http://blog.csdn.net/lelewenzibin/article/details/42713585 问题描述 Mybatis有个代码生成工具,生成的代码里面有mapper.xm ...