这几天好像都在疯狂的查MFC的资料~~~~,终于想起来要 写一篇自己出的题的题解的博客了。。
挺奇怪的,写自己出的题的题解,不过还是有必要写一下的,毕竟是一次属于自己的思考嘛~~~~
问题虫洞——1550:1550.你的心态炸了嘛?
黑洞内窥:
题目给出多组数据,每组数据包括n,a,b和c四个数字。
要求你求出第n个可以被a或b或c整除的正整数。
(1<=n, a, b, c <=10^9,a!=b!=c。答案保证在2^31-1范围内)
思维光年:
容斥+二分(直接看代码)
ACcode:
//#include<bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include<algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <cstring>
#include <string.h>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
#define MAXN 2000000010;
#define INF 0x3f3f3f3f//将近ll类型最大数的一半,而且乘2不会爆ll
ll gcd(ll a, ll b){return b==0? a: gcd(b, a%b);}
int main()
{
ll n, a, b, c;
while(~scanf("%lld %lld %lld %lld", &n, &a, &b, &c))
{
ll ab = a*b/gcd(a, b);
ll ac = a*c/gcd(a, c);
ll bc = b*c/gcd(b, c);
ll abc = a*bc/gcd(a, bc);
ll l=0, r=MAXN;
while(l < r)
{
ll mid = l + (r-l)/2;
ll ans = mid/a+mid/b+mid/c-mid/ab-mid/bc-mid/ac+mid/abc;
if(ans<n) l = mid+1;
else r = mid;
}
cout << l << '\n';
}
return 0;
}
问题虫洞——1552:1552.畅游王者峡谷
黑洞内窥:
Treatment,Sprint,Smite,End,Rage,Interfere,Vertigo,Purify,Weaken,Flash
十个召唤师技能无限重复的排成一个序列(Treatment开始,Flash结束,然后不断重复),夫子输入一个n(多组),求第(1^1+2^2+3^3+4^4+5^5+……+(n-1)^n-1+n^n)个召唤师技能是什么?(1<=n<=500000)
思维光年:
快速幂暴力
ACcode:
//#include<bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include<algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <cstring>
#include <string.h>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
#define MAXN 500005
#define INF 0x3f3f3f3f//将近ll类型最大数的一半,而且乘2不会爆ll
int a[MAXN];
string s[11] = {"0", "Treatment", "Sprint", "Smite", "End", "Rage",
"Interfere", "Vertigo", "Purify", "Weaken", "Flash"};
ll qpow(ll a, ll b)
{
ll ans=1;
while(b)
{
if(b&1)
ans = ans*a%10;
a = a*a%10;
b >>= 1;
}
return ans%10;
}
void init()
{
for(ll i=1; i<=MAXN; ++i)
a[i] = (a[i-1]+qpow(i, i))%10;
}
int main()
{
init();
int n;
while(~scanf("%d", &n))
if(a[n] == 0) cout << s[10] << '\n';
else cout << s[a[n]] << '\n';
return 0;
}
我就出了这两题,没什么好考察的,题目也是中文~~~~emmm