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. python2.0_s12_day12_css样式详解

    CSScss是英文Cascading Style Sheets的缩写,称为层叠样式表,用于对页面进行美化. CSS 存放方式有三种: 一种写法:在<body></body>内部 ...

  2. laravel 使用 session

    配置方面的不写了,请参考学院君的文章:http://laravelacademy.org/post/5898.html 在开始之前先说一下,使用 request 对象的 session() 方法,和直 ...

  3. cmp()

    cmp(x, y) 用于比较两个对象的大小,如果 x > y 返回 1 ,如果 x = y 返回 0 ,如果 x < y 返回 -1 In [23]: cmp(5, 2) Out[23]: ...

  4. Bootloader之uBoot简介(转)

    来自http://blog.ednchina.com/hhuwxf/1915416/message.aspx,感谢作者 一.Bootloader的引入从前面的硬件实验可以知道,系统上电之后,需要一段程 ...

  5. Mybaits中的update

    <update id="update" parameterType="Currency"> UPDATE YZ_SECURITIES_CURRENC ...

  6. 安装postgresql之后为什么找不到postgresql service

    没有正常启动 postgresql service.可以 在运行里面 输入 services.msc 找到 postgresql 的服务.启动他.或者也可以用postgres 自带的 工具pg_ctl ...

  7. 5个基于Web的建模工具

    本文介绍 5 款很棒的直接可以在浏览器使用的建模工具,无需单独安装软件. 1. Creately提供在线图表和协助功能,包含多种建模语言(UML)支持,这里有一个简单的演示:here 2.Diagra ...

  8. js插件---->jquery通知插件toastr的使用

    toastr是一款非常棒的基于jquery库的非阻塞通知提示插件,toastr可设定四种通知模式:成功,出错,警告,提示,而提示窗口的位置,动画效果都可以通过能数来设置.toastr需要jquery的 ...

  9. Linux学习——定义命令行函数(cd .. -> ..)

    在使用shell的时候,每天要面对各种命令行,比如ls , cd .. 等 抱着简单,可依赖的思想.有些可以简化的操作可以要通过在 ~/.bashrc 中进行添加: 1. cd .. -> .. ...

  10. LeetCode——Add Digits

    Description: Given a non-negative integer num, repeatedly add all its digits until the result has on ...