看到10000000个数中求最大的lcm感觉很难,但是数据随机
于是搞一百个最大的数字,100*100扫一遍就稳了(滑稽
#include <bits/stdc++.h> using namespace std; typedef int ll; inline ll read() { ll s=0; bool f=0; char ch=' '; while(!isdigit(ch)) {f|=(ch=='-'); ch=getchar();} while(isdigit(ch)) {s=(s<<3)+(s<<1)+(ch^48); ch=getchar();} return (f)?(-s):(s); } #define R(x) x=read() inline void write(ll x) { if(x<0) {putchar('-'); x=-x;} if(x<10) {putchar(x+'0'); return;} write(x/10); putchar((x%10)+'0'); } #define W(x) write(x),putchar(' ') #define Wl(x) write(x),putchar('\n') const int N=105; #define ull unsigned long long unsigned T,n,A,B,C,x,y,z; ull a[N]; inline unsigned tang() { unsigned t; x^=x<<16; x^=x>>5; x^=x<<1; t=x; x=y; y=z; z=t^x^y; return z; } inline ull gcd(ull x,ull y) { return (y==0)?(x):(gcd(y,x%y)); } signed main() { unsigned i,j,t,wwx,cnt; ull lwj; scanf("%u",&T); for(t=1;t<=T;t++) { scanf("%u%u%u%u",&n,&A,&B,&C); x=A; y=B; z=C; cnt=0; lwj=0; priority_queue<ull,vector<ull>,greater<ull> >pq; for(i=1;i<=100;i++) pq.push(0); for(i=1;i<=n;i++) { wwx=tang(); if(wwx>pq.top()) { pq.pop(); pq.push(wwx); } } while(pq.size()>0) { if(pq.top()!=0) { a[++cnt]=pq.top(); } pq.pop(); } for(i=1;i<=min(n,cnt)-1;i++) { for(j=i+1;j<=min(n,cnt);j++) { lwj=max(lwj,a[i]/gcd(a[i],a[j])*a[j]); } } printf("Case #%d: %llu\n",t,lwj); } return 0; }View Code