数论一道题也不会,下午考试怎么办啊!!
题目链接:
思路:
然后就改一下下快读,直接暴力搞... 但是只得了10分,WOC!!
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<vector>
#define ll long long int
#include<stack>
#include<queue>
using namespace std;
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 % 19260817;
}
ll quickpow(ll a, int b) {
ll ret = 1;
while(b) {
if(b & 1)
ret = ret*a%19260817;
a=a*a% 19260817;
b>>=1;
}
return ret%19260817;
}
int main() {
ll a = read(), b = read();
if(!b) {
printf("Angry!
");
return 0;
}
ll ans = (a%19260817)*(quickpow(b,19260817-2)%19260817)%19260817;
cout<<ans%19260817;
}
后来看了大佬的题解又比着打了一遍,太菜了
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
#define enter puts("")
#define space putchar(' ')
#define Mem(a, x) memset(a, x, sizeof(a))
#define rg register
typedef long long ll;
typedef double db;
const int INF = 0x3f3f3f3f;
const db eps = 1e-8;
const int mod = 19260817;
inline ll read()
{
ll ans = 0;
char ch = getchar(), last = ' ';
while(!isdigit(ch)) {last = ch; ch = getchar();}
while(isdigit(ch)) {ans = ans * 10 % mod + ch - '0'; ch = getchar();}
ans %= mod;
if(last == '-') ans = -ans;
return ans;
}
inline void write(ll x)
{
if(x < 0) x = -x, putchar('-');
if(x >= 10) write(x / 10);
putchar(x % 10 + '0');
}
ll quickpow(ll a, int b)
{
ll ret = 1;
while(b)
{
if(b & 1) ret = ret * a % mod;
a = a * a % mod; b >>= 1;
}
return ret;
}
int main()
{
ll a = read(), b = read();
if(!b) {printf("Angry!
"); return 0;}
ll ans = a * quickpow(b, mod - 2) % mod;
write(ans); enter;
}