标签:而且 color == turn scanf spl amp 独立 match
题解:第一题:
打表找规律,从12以后每次加49,我一直在前十找规律,,找了半天,以后还是多打点,学聪明点
#include <bits/stdc++.h> #define ll long long using namespace std; int zl[4] = {1,5,10,50}; ll ans[] = {0,4,10,20,35,56,83,116,155,198,244,292,341,390,439,488,537,586,635,684,733,782,831,880,929,978,1027,1076,1125,1174,1223,1272,1321,1370,1419,1468,1517,1566,1615,1664,1713,1762,1811,1860,1909,1958,2007,2056,2105,2154,2203,2252,2301,2350,2399,2448,2497,2546,2595,2644,2693,2742,2791,2840,2889,2938,2987,3036,3085,3134,3183,3232,3281,3330,3379,3428,3477,3526,3575,3624,3673,3722,3771,3820,3869,3918,3967,4016,4065,4114,4163,4212,4261,4310,4359,4408,4457,4506,4555,4604,4653}; int Ans = 0; int main() { freopen("a.in","r",stdin); freopen("a.out","w",stdout); ll n; scanf("%I64d", &n); if(n <= 12)printf("%I64d\n", ans[n]); else printf("%I64d\n", 49* (n - 12) + ans[12]); }
第二题:
这是一道傻逼题,但我就是没想出来,利用log单增函数就好了,比较log2 x^y. log2 y^x ‘即 ylog2x xlog2y
#include <bits/stdc++.h> using namespace std; int main() { freopen("b.in","r",stdin); freopen("b.out","w",stdout); int T; scanf("%d", &T); while(T--){ double a, b; scanf("%lf%lf", &a, &b); if(a == b){puts("=");continue;} if(a == 1 && b > 1){puts("<");continue;} if(b == 1 && a > 1){puts(">");continue;} if(a*log(b) > b*log(a)){puts("<");continue;} if(a*log(b) < b*log(a)){puts(">");continue;} puts("="); //printf("%d\n", work(a, b, x, y, aa, bb)); } return 0; }
第三题:
这道题最开始看着像上司的舞会,但简单画画图就知道会成环,然后就二分图匹配,原题是bzoj数字匹配,把数按质因子个数奇偶拆成两组,最大点独立集
#include <bits/stdc++.h> #define ll long long using namespace std; const int M = 500005; int a[M], tmp[M]; bool check(int a, int b){ if(a > b)swap(a, b); if(b%a)return 0; int d = b/a; for(int i = 2; i <= d; i++){ if(d%i == 0 && d != i)return 0; } return 1; } struct {int id, val;}odd[M], even[M]; int h[M], match[M], tot, cnt, t2, t1; bool vis[M]; struct edge{int v,nxt;}G[M<<1]; void add(int u, int v){G[++tot].nxt=h[u]; h[u]=tot; G[tot].v=v;} void init(){ memset(h, 0, sizeof(h)); memset(match, 0, sizeof(match)); tot = cnt = t1= t2 = 0; } bool find(int u){ for(int i = h[u]; i; i = G[i].nxt){ int v = G[i].v; if(vis[v])continue; vis[v] = 1; if(!match[v] || find(match[v])){ match[v] = u; return 1; } } return 0; } int main() { freopen("c.in","r",stdin); freopen("c.out","w",stdout); int T; scanf("%d", &T); while(T--){ int n, ans = 0, cur = 0; scanf("%d", &n); init(); for(int i = 1; i <= n; i++){ scanf("%d", &a[i]); int tt = a[i]; int cnt = 0; for(int j = 2; j <= a[i]; j++) if(a[i]%j == 0){ while(a[i]%j == 0) a[i] /= j, cnt++; } if(cnt & 1) odd[++t1].val = tt, odd[t1].id = ++cur; else even[++t2].val = tt, even[t2].id = ++cur; } for(int i = 1; i <= t1; i++) for(int j = 1; j <= t2; j++) if(check(odd[i].val, even[j].val))add(odd[i].id, even[j].id); for(int i = 1; i <= t1; i++){ memset(vis, 0, sizeof(vis)); if(find(odd[i].id)) ans++; } printf("%d\n", n - ans); } return 0; }
标签:而且 color == turn scanf spl amp 独立 match
原文地址:https://www.cnblogs.com/EdSheeran/p/9460615.html