心路历程

预计得分:\(100 + 100 + 50\)

实际得分:\(100 + 100 + 50\)

感觉老师找的题有点水呀。

上来看T1,woc?裸的等比数列求和?然而我不会公式呀。。感觉要凉

T2应该比较简单,T3 dp能拿很多部分分。

但是T1只打暴力感觉好丢人啊。。想了10min发现不用公式也能做,就直接倍增一下就好了。

T2水题。感觉比T1还简单。。

T3。。。。。这个就比较厉害了呀。赛后我大概问了一下,发现全机房一共读出了\(4\)种题意Orzzz。

然后我花了\(2h\)做了一道水题。。然后发现错误的时候考试马上就结束了,然后只能打个暴力走人。。。

T1

Orz zbq现场推出等比数列求和公式

Orz 好像除了我都会等比数列求和公式

Orzzzzzzzzzzzzzzzzz

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<iostream>
using namespace std;
const int MAXN =1e5 + 10, mod = 1e9 + 7;
inline int read() {
char c = getchar(); int x = 0, f = 1;
while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return x * f;
}
int add(int x, int y) {
if(x + y < 0) return x + y + mod;
return x + y >= mod ? x + y - mod : x + y;
}
int mul(int x, int y) {
return 1ll * x * y % mod;
}
int fp(int a, int p) {
int base = 1;
while(p) {
if(p & 1) base = mul(base, a);
a = mul(a, a); p >>= 1;
}
return base;
}
int N, M, pok[MAXN], g[MAXN];
int solve(int k, int n) {
int len = 1;
while((1ll << len) <= n) len <<= 1;
pok[0] = k;
for(int i = 1; i <= len; i++) pok[i] = mul(pok[i - 1], pok[i - 1]);
g[0] = k;
for(int i = 1; i <= len; i++) g[i] = add(g[i - 1], mul(g[i - 1], pok[i - 1]));
int ans = 0, now = 0, base = 1;
for(int i = len; i >= 0; i--)
if(now + (1 << i) <= n)
ans = add(ans, mul(g[i], base)), base = mul(base, pok[i]), now += (1 << i);
return ans;
}
main() {
freopen("sum.in", "r", stdin);
freopen("sum.out", "w", stdout);
N = read(); M = read();
int ans = 0;
for(int i = 1; i <= N; i++) {
if(M & 1) ans = add(ans, add(solve(i, M - 1), fp(i, M)));
else ans = add(ans, solve(i, M));
// cout << ans << endl;
}
cout << ans;
return 0;
}

T2

\(ans = all - min(sum[i])\)

all表示所有边权和

\(sum[i]\)表示第\(i\)个节点到根的路径

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<iostream>
#define Pair pair<int, int>
#define MP make_pair
#define fi first
#define se second
using namespace std;
const int MAXN = 1e5 + 10, INF = 1e9 + 7;
inline int read() {
char c = getchar(); int x = 0, f = 1;
while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return x * f;
}
int N, sum[MAXN], All;
vector<Pair> v[MAXN];
void dfs(int x, int fa) {
for(int i = 0, to; i < v[x].size(); i++) {
if((to = v[x][i].fi) == fa) continue;
sum[to] = sum[x] + v[x][i].se;
dfs(to, x);
}
}
int main() {
freopen("tour.in", "r", stdin);
freopen("tour.out", "w", stdout);
N = read();
for(int i = 1; i <= N - 1; i++) {
int x = read(), y = read(), z = read(); All += z;
v[x].push_back(MP(y, z));
v[y].push_back(MP(x, z));
}
dfs(1, 0);
All <<= 1;
int ans = INF;
for(int i = 1; i <= N; i++) ans = min(ans, All - sum[i]);
cout << ans;
return 0;
}

T3

神仙阅读理解题,不过还是挺interesting的

首先,序列内的元素是无序的,这样我们可以对相同的数字一起考虑

稍微想一下不难发现,幸运数字最多有\(2^9\)个

直接\(f[i][j]\)表示前\(i\)个数,选\(j\)的方案,dp一下

最后合并答案的时候背包一下

#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#include<set>
#include<bitset>
#include<iostream>
#include<map>
#define Pair pair<int, int>
#define MP make_pair
#define fi first
#define se second
//#define int long long
using namespace std;
const int MAXN = 1e5 + 10, mod = 1e9 + 7;
inline int read() {
char c = getchar(); int x = 0, f = 1;
while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return x * f;
}
int N, K, a[MAXN], tot, cnt, fac[MAXN], ifac[MAXN];
map<int, int> mp;
int add(int &x, int y) {
if(x + y < 0) x = x + y + mod;
else x = (x + y >= mod ? x + y - mod : x + y);
}
int add2(int x, int y) {
if(x + y < 0) return x + y + mod;
else return x + y >= mod ? x + y - mod : x + y;
}
int mul(int x, int y) {
return 1ll * x * y % mod;
}
int fp(int a, int p) {
int base = 1;
while(p) {
if(p & 1) base = mul(base, a);
a = mul(a, a); p >>= 1;
}
return base;
}
int C(int N, int M) {
if(N < M) return 0;
else return mul(fac[N], mul(ifac[M], ifac[N - M]));
}
int get(int x) {
while(x) {
if(x % 10 != 4 && x % 10 != 7) return 0;
else x /= 10;
}
return 1;
}
map<int, Pair> id;
int rev[MAXN], f[2333][2333];
signed main() {
freopen("lucky.in", "r", stdin);
freopen("lucky.out", "w", stdout);
N = read(); K = read();
fac[0] = 1;
for(int i = 1; i <= N; i++) fac[i] = mul(i, fac[i - 1]);
ifac[N] = fp(fac[N], mod - 2);
for(int i = N; i >= 1; i--) ifac[i - 1] = mul(ifac[i], i); for(int i = 1; i <= N; i++) {
a[i] = read();
if(get(a[i])) {
if(!id[a[i]].fi) id[a[i]].fi = ++cnt, rev[cnt] = a[i];
id[a[i]].se++;
} else tot++;
}
f[0][0] = 1;
for(int i = 1; i <= cnt; i++) {
f[i][0] = 1;
for(int j = 1; j <= cnt; j++)
f[i][j] = add2(f[i - 1][j], mul(f[i - 1][j - 1], id[rev[i]].se));
} int ans = 0;
for(int i = 0; i <= cnt; i++) add(ans, mul(f[cnt][i], C(tot, K - i)));
cout << ans; return 0;
}

11.1NOIP模拟赛解题报告的更多相关文章

  1. 11.7NOIP模拟赛解题报告

    心路历程 预计得分:\(50 + 100 + 100\) 实际得分:\(50 + 100 +100\) T2 T3两道数据结构题美滋滋,然而写完就过去\(3h\)美滋滋 T1数学题学弟们都会做Orzz ...

  2. 11.6NOIP模拟赛解题报告

    心路历程 预计得分:\(100 + 100 + 100 = 300\) 实际得分:\(100 +100 +100 = 300\) 学OI两年终于AK了一次qwq(虽然题目炒鸡水..) 纪念一下这令人激 ...

  3. 11.5NOIP模拟赛解题报告

    心路历程 预计得分:\(100 + 40 + 30 = 170\) 实际得分:\(100 +100 + 50 = 250\) 辣鸡数据毁我青春 T1一眼不会做感觉要凉 T2好像一波折半搜索就做完了 T ...

  4. 10.30 NFLS-NOIP模拟赛 解题报告

    总结:今天去了NOIP模拟赛,其实是几道USACO的经典的题目,第一题和最后一题都有思路,第二题是我一开始写了个spfa,写了一半中途发现应该是矩阵乘法,然后没做完,然后就没有然后了!第二题的暴力都没 ...

  5. 20201101gryz模拟赛解题报告

    写在前面 2020rp++ 停课的第一场模拟赛 拿上一年的上一年的day1来考的, 结果得分期望220pts,实际135pts,rank3,太菜了 考着考着机房灯突然灭了,当时慌的一批 以为断电代码要 ...

  6. 2018.10.26NOIP模拟赛解题报告

    心路历程 预计得分:\(100 + 100 + 70\) 实际得分:\(40 + 100 + 70\) 妈妈我又挂分了qwq..T1过了大样例就没管,直到临考试结束前\(10min\)才发现大样例是假 ...

  7. 2018.10.17NOIP模拟赛解题报告

    心路历程 预计得分:\(100 + 100 +100\) 实际得分:\(100 + 100 + 60\) 辣鸡模拟赛.. 5min切掉T1,看了一下T2 T3,感觉T3会被艹爆因为太原了.. 淦了20 ...

  8. 2018.10.16 NOIP模拟赛解题报告

    心路历程 预计得分:\(100 + 100 + 20 = 220\) 实际得分:\(100 + 100 + 30 = 230\) 辣鸡模拟赛.. T1T2都是一眼题,T3考验卡常数还只有一档暴力分. ...

  9. 20201115gryz模拟赛解题报告

    写在前面 T1:期望100pts,实际0pts(7:50 ~ 8:50 T2:期望0pts,实际0pts(10:00 ~ 10:35 T3:期望20pts,实际40pts( 9:10 ~ 10:00, ...

随机推荐

  1. P5108 仰望半月的夜空 SAM+线段树覆盖

    $ \color{#0066ff}{ 题目描述 }$ 半月的夜空中,寄托了多少人与人之间的思念啊 曦月知道,这些思念会汇集成一个字符串\(S(n = |S|)\) 由于思念汇集的过于复杂,因此曦月希望 ...

  2. 方法引用(Method reference)和invokedynamic指令详细分析

    方法引用(Method reference)和invokedynamic指令详细分析 invokedynamic是jvm指令集里面最复杂的一条.本文将详细分析invokedynamic指令是如何实现方 ...

  3. ssh访问流程

    SSH是英文Secure Shell的简写形式.通过使用SSH,你可以把所有传输的数据进行加密,这样"中间人"这种攻击方式就不可能实现了,而且也能够防止DNS欺骗和IP欺骗.使用S ...

  4. js 鼠标拖拽效果实现

    效果: 源码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="U ...

  5. Codeforces Round #545 (Div. 2) 题解

    题目链接 A. Sushi for Two 题意 在一个 01 序列中找出长为偶数的连续的一段使得它前一半和后一半内部分别相同,而前一半和后一半不同. \(2\le n\le 100\ 000\) 题 ...

  6. ZOJ - 3649 树上倍增

    题意:给出一个图,先求出最大生成树,然后多次询问树上路径\(u→v\)的有向最大极差\(max(a_i-a_j),i>j\),其中\(i\)和\(j\)指代节点在路径中出现的顺序 极差具有单调性 ...

  7. GTP

     GPRS隧道协议(GPRS Turning Protocol) GTP是一个高层协议,位于TCP/IP或UDP/IP等协议上,提供主机间端到端通信, 通过隧道标志(TEI)在路径协议上复用  GTP ...

  8. Ubuntu16.04+Cuda8.0+cuDNN6配置py-faster rcnn(转)

    原博客地址:https://blog.csdn.net/meccaendless/article/details/79557162 0前言Faster R-CNN是任少卿2015年底推出的目标检测算法 ...

  9. nginx响应码

    ngx.status = ngx.HTTP_CONTINUE (100) (first added in the v0.9.20 release)ngx.status = ngx.HTTP_SWITC ...

  10. Android中直接打开高德APP进行导航

    1.判断是否安装有高德APP //高德APPprivate PackageManager mPackageManager;private static List<String> mPack ...