HDU 5478 Can you find it 随机化 数学
来源:互联网 发布:java游戏魔幻西游 编辑:程序博客网 时间:2024/04/30 03:18
题意
问你有多少对数,满足a^(k1⋅n+b1) + b^(k2⋅n−k2+1) = 0 (mod C)
题解:
首先你要知道,对于每个a只有唯一对应的b可以满足这个式子,因为当n=1的时候,a^(k1+b1)+b = kk*C
由于b是小于c的,所以只有一个
所以我们可以求出b来,然后我们怎么check这个b究竟是不是呢?
随机化10个数,然后随便check就好了
//qscqesze#pragma comment(linker, "/STACK:1024000000,1024000000")#include <cstdio>#include <cmath>#include <cstring>#include <ctime>#include <iostream>#include <algorithm>#include <set>#include <bitset>#include <vector>#include <sstream>#include <queue>#include <typeinfo>#include <fstream>#include <map>#include <stack>typedef long long ll;using namespace std;//freopen("D.in","r",stdin);//freopen("D.out","w",stdout);#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)#define maxn 100006#define mod 1000000007#define eps 1e-9#define e exp(1.0)#define PI acos(-1)const double EP = 1E-10 ;int Num;//const int inf=0x7fffffff;const ll inf=999999999;inline ll read(){ ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f;}//*************************************************************************************ll fMul(int m,ll n,int k){ ll cc = m; ll b = 1; while (n > 0) { if (n & 1LL) { b = (b*cc); if(b>=k) b%=k; } n = n >> 1LL ; cc = (cc*cc)%k; if(cc>=k)cc%=k; } return b;}int main(){ //freopen("out.txt","r",stdin); //freopen("out2.txt","w",stdout); srand(time(NULL)); int tot = 1; int c ,k1 ,b1 ,k2; while(scanf("%d%d%d%d",&c,&k1,&b1,&k2)!=EOF) { printf("Case #%d:\n",tot++); int flag1 = 0; for(int i=1;i<c;i++) { int j=c-fMul(i,k1*1+b1,c); int flag = 1; for(int k=1;k<=15;k++) { ll tt = rand()%c+1; ll ttt1 = k1, ttt2 = k2,ttt3 = b1; if((fMul(i,ttt1*tt+ttt3,c)+fMul(j,ttt2*tt-ttt2+1LL,c))%c!=0) { flag = 0; break; } } if(flag) { printf("%d %d\n",i,j); flag1=1; } } if(!flag1) printf("-1\n"); }}
0 0
- HDU 5478 Can you find it 随机化 数学
- [随机化] HDU 5478 Can you find it
- HDU 5478 Can you find it (数学_随机化,取特殊值!!!)
- HDU 5478 Can you find it
- hdu 5478 Can you find it 测试
- HDU 5478 Can you find it
- HDU 5478 Can you find it
- HDU Can you find it?
- 2015上海网络赛 HDU 5478 Can you find it 数学
- hdu5478 Can you find it(数学规律)
- hdu5478 Can you find it(数学)
- hdu 5478 Can you find it(数论)
- HDU/HDOJ 2141 Can you find it?
- HDU 1241 Can you find it?
- hdu 2141 can you find it?
- hdu 2142 Can you find it?
- HDU-2141 can you find it?
- hdu 2141 Can you find it?
- Ecstore官方视频教程
- Rails框架搭建
- ActiveMQ消息队列获取每个队列中的消费者数、剩余消息数、已消费数、队列名等信息 示例
- 【数据结构】C语言实现单链表
- 32个最热CPLD-FPGA论坛
- HDU 5478 Can you find it 随机化 数学
- Ecstore官方视频教程
- 计算字符串中的单词数. 单词:由空格分开的连续字母数字串。
- Python 文件读写操作
- 在亚马逊云服务器上部署阿里数据库Otter(一)
- Eclipse报错:java.lang.ClassNotFoundException: ContextLoaderListener
- 定时发布
- lua 实现从ftp获取文件,并把文件部分内容记mysql
- 宏和函数的区别