国庆集训 || Wannafly Day4
链接:https://www.nowcoder.com/acm/contest/205#question
一场题面非常 有趣 但是题目非常 不友好的比赛
QAQ
L.数论之神 思维(?)
题意:求对给定的n,中有多少个不同的数,并且这些不同的数中第k大的是多少
思路:打表找了找规律(感觉自己天天都在找规律。。),对于不同的n,不同的结果中,≤sqrt(n)的一定都有,剩下的直接除就ok了
整数除法:https://blog.csdn.net/qq_39792342/article/details/82783100
艾玛说不明白话,还是适合直接找规律(哭
#include <iostream> #include <cstdio> #include <cmath> using namespace std; typedef long long LL; int main() {int T;scanf("%d", &T);while(T--){LL n, k, sq, cnt;scanf("%lld%lld", &n, &k);sq = (LL)sqrt(double(n));if(n < sq*(sq+1)) cnt = sq+sq-1;else cnt = sq+sq;printf("%lld ", cnt);if(k <= cnt-sq) printf("%lld\n", n/k);else printf("%lld\n", cnt+1-k);} }
View Code
G.贵族用户 暴力嘤嘤嘤
勾起了我一年前玩奇迹暖暖养女儿的回忆QAQ (女儿你还好吗~~
题意:花x元获得10x个钻石,ai个钻石可以使得原价为di的服装价格变为,要买ci件价格为di的衣服,问最少氪多少钱
思路:暴力枚举得到每一档的打折,求最少的钱数
注意1.可能不氪金反而更便宜
2.享受pi折扣的时候,要保证氪的钻石>=a[i],因此所需的钻石是max(钻石, a[i])
3.向上取整的时候可以,比如除以100然后向上取整 -> (x+99)/100
4.好坑啊好坑啊
#include <iostream> #include <stdio.h> #include <string.h> #include <math.h> using namespace std; int c[22], d[22], a[22], p[22]; int main() {int T;scanf("%d", &T);while(T--){int m, k;scanf("%d%d", &m, &k);for(int i = 0; i < m; i++)scanf("%d%d", &a[i], &p[i]);int sum = 0;for(int i = 0; i < k; i++)scanf("%d%d", &c[i], &d[i]), sum += c[i]*d[i];int ans = 1000000000, ans_novip = sum;for(int i = 0; i < m; i++){int sum_vip = 0;for(int j = 0; j < k; j++)sum_vip += (d[j] * (100-p[i]) + 99) / 100 * c[j];sum_vip = min(max(sum_vip, a[i]), ans_novip);ans = min(ans, sum_vip);}printf("%d\n", (ans+9)/10);}return 0; }
View Code
B.电音之王 快速乘操作666
题意:已知a0,a1,m0,m1,c,定义an=m0an-1+m1an-2+c (n≥ 2)
求,(保证
思路:直接暴力是O(10^8)的,又有模运算,so 优化叭
太高级了。。。64位模,板子收下了orz
#include <iostream> #include <cstdio> #include <cassert> #include <cmath> using i64 = long long; using u64 = unsigned long long; using u128 = __uint128_t; struct Mod64 {Mod64() : n_(0) {}Mod64(u64 n) : n_(init(n)) {}static u64 modulus() { return mod; }static u64 init(u64 w) { return reduce(u128(w) * r2); }static void set_mod(u64 m){mod = m;assert(mod & 1);inv = m;for (int i = 0; i < 5; ++i)inv *= 2 - inv * m;r2 = -u128(m) % m;}static u64 reduce(u128 x){u64 y = u64(x >> 64) - u64((u128(u64(x) * inv) * mod) >> 64);return i64(y) < 0 ? y + mod : y;}Mod64 &operator+=(Mod64 rhs){n_ += rhs.n_ - mod;if (i64(n_) < 0)n_ += mod;return *this;}Mod64 operator+(Mod64 rhs) const { return Mod64(*this) += rhs; }Mod64 &operator*=(Mod64 rhs){n_ = reduce(u128(n_) * rhs.n_);return *this;}Mod64 operator*(Mod64 rhs) const { return Mod64(*this) *= rhs; }u64 get() const { return reduce(n_); }static u64 mod, inv, r2;u64 n_; }; u64 Mod64::mod, Mod64::inv, Mod64::r2;inline u64 mod128_64_small(u128 a, u64 b) {u64 q, r;__asm__("divq\t%4": "=a"(q), "=d"(r): "0"(u64(a)), "1"(u64(a >> 64)), "rm"(b));return r; }u64 fact_mod_fast(int N, u64 mod) {Mod64::set_mod(mod);Mod64 ret = Mod64(1), one = ret, t = one;for (int i = 1; i <= N; ++i){ret *= t;t += one;}return ret.get(); } int main() {int T;scanf("%d", &T);while(T--){u64 a0_, a1_, m0_, m1_, c_, M, k;scanf("%llu%llu%llu%llu%llu%llu%llu", &a0_, &a1_, &m0_, &m1_, &c_, &M, &k);Mod64 :: set_mod(M);Mod64 a0 = Mod64(a0_);Mod64 a1 = Mod64(a1_);Mod64 m0 = Mod64(m0_);Mod64 m1 = Mod64(m1_);Mod64 c = Mod64(c_);Mod64 ans = a0*a1;Mod64 a2;for(int i = 2; i <= k; i++){a2 = m0*a1+m1*a0+c;ans = ans * a2;a0 = a1;a1 = a2;}printf("%llu\n", ans.get());} }
View Code
快速乘的模板↓
LL multi(LL x,LL y,LL mod) {LL tmp = (x * y - (LL)((long double) x / mod * y + 1.0e-8) * mod);return tmp < 0 ? tmp+mod : tmp;//x*y%mod }
View Code
转载于:https://www.cnblogs.com/pinkglightning/p/9746175.html
国庆集训 || Wannafly Day4相关推荐
- 2020牛客国庆集训派对day4 Jokewithpermutation
Jokewithpermutation 题目描述 Joey had saved a permutation of integers from 1 to n in a text file. All th ...
- 2020牛客国庆集训派对day4 What Goes Up Must Come Down
What Goes Up Must Come Down 题意: 我们规定一个序列合理:当一个序列左部分是非降序列,右部分是非升序列(左右部分可为0,也就是整体可以为非降序列,非升序列) 题解: 树状数 ...
- 2020牛客国庆集训派对day4 Arithmetic Progressions
Arithmetic Progressions 链接:https://ac.nowcoder.com/acm/contest/7831/B 来源:牛客网 题目描述 An arithmetic prog ...
- 2020牛客国庆集训派对day4 Emergency Evacuation
Emergency Evacuation 题意: 有n个人在不同的位置上,在最后面有一个出口exit,所有人都要逃离出去(走出出口),且每个格子最多容纳一个人,当有人挡在前面时,后面的人必须停留,所有 ...
- 2020牛客国庆集训派对day4 Digits Are Not Just Characters
Digits Are Not Just Characters 题意: 比较大小,如果比目标字符串大输出"+",相等也输出"+",小则输出"-" ...
- 牛客国庆集训派对Day6
牛客国庆集训派对Day6 以下是我个人题解,出题人题解附带在最后 A.Birthday 费用流裸题,只要注意到1+3+5+...+2k−1=k21+3+5+...+2k-1 = k^21+3+5+.. ...
- 2019牛客国庆集训派对day2 K 2018(容斥)
链接:https://ac.nowcoder.com/acm/contest/1107/K 来源:2019牛客国庆集训派对day2 题目描述 Given a, b, c, d, find out ...
- 2020牛客国庆集训派对day2 补题J
2020牛客国庆集训派对day2 补题J:VIRUS OUTBREAK 题目描述 The State Veterinary Services Department recently reported ...
- 2020牛客国庆集训派对day3 I.Rooted Tree(哈代-拉马努金拆分数列)
2020牛客国庆集训派对day3 I.Rooted Tree(哈代-拉马努金拆分数列) 题目 https://ac.nowcoder.com/acm/contest/7830/I 题意 给你n个点,问 ...
最新文章
- Google因数据泄露关闭Google+消费者版本
- 百度java验证码不显示不出来,Java-使用百度链接时,遇到无法弹出用户登录框的问题...
- 32位微型计算机quot;中的32指的是,《计算机应用基础作业一).doc
- Vs2008不能调试的问题
- 特岗计算机老师年度总结,特岗教师个人年度工作总结
- Android NDK调试定位错误
- mac环境下node.js和phonegap/cordova创建ios和android应用
- scala学习-scala通过mkString方法把一个集合转化为一个字符串
- 将后台的返回的格式,根据某个共同的字段分组
- matlab实对称矩阵对角化,基于Matlab的实对称矩阵对角化
- Application.DoEvents()的作用
- USACO 2016 JANUARY CONTEST, BRONZE PROBLEM 3. MOWING THE FIELD(收割庄稼)
- 如何实现 ASP.NET Core WebApi 的版本化
- 傅立叶变换系列(二)傅立叶级数
- centos 更新时间
- mysql查询当前用户中所有的表空间_oracle 查看用户所在的表空间
- 机器学习小组知识点36:FCM聚类
- Win7安装.Net Framework 4.5.2失败最有效的解决方法
- 网站QQ客服链接代码
- 计算机专业毕业答辩问代码吗,计算机专业毕业论文答辩技巧