火影战记差不多的游戏的pank c

A. Base $i - 1$ Notation
两个性质:
利用这两条性质实现高精度加法即可。
时间复杂度$O(n)$。
#include&stdio.h&
#include&iostream&
#include&string.h&
#include&string&
#include&ctype.h&
#include&math.h&
#include&set&
#include&map&
#include&vector&
#include&queue&
#include&bitset&
#include&algorithm&
#include&time.h&
const int N = 6e6 + 10;
const int inf = 1e9;
int casenum,
char a[N], b[N];
int main()
freopen("base-i-1.in","r",stdin); freopen("base-i-1.out","w",stdout);
while(~scanf("%s%s", a, b))
int n = strlen(a); reverse(a, a + n);
int m = strlen(b); reverse(b, b + m);
//int n = 5e5; for(int i = 0; i & ++i)a[i] = '1'; a[n] = 0;
//int m = 5e5; for(int i = 0; i & ++i)b[i] = '1'; b[m] = 0;
int g = max(n, m);
for(int i = 0; i & ++i)
int p = i / 2;
if(i & n)c[i] += a[i] - 48;
if(i & m)c[i] += b[i] - 48;
for(int i = 0; i & ++i)
int t=min(c[i]/2,min(c[i+1]/2,c[i+2]));
c[i]-=t*2;
c[i+1]-=t*2;
c[i+2]-=t;
int w = c[i] / 2;
c[i + 2] +=
c[i + 3] +=
g = max(g, i + 4);
c[i] %= 2;
while(g&1&&!c[g-1])g--;
for(int i = g - 1; i &= 0; --i)printf("%d", c[i]);
B. Squaring a Bit
直接暴力枚举平方数即可通过,需要手写popcount。
#include&stdio.h&
#include&iostream&
#include&string.h&
#include&string&
#include&ctype.h&
#include&math.h&
#include&set&
#include&map&
#include&vector&
#include&queue&
#include&bitset&
#include&algorithm&
#include&time.h&
const int N = 3e5 + 10;
typedef long long LL;
int v[65555];
int popcount(LL x){
return v[x&65535]+v[x&&16&65535]+v[x&&32&65535]+v[x&&48];
int main()
for(int i=1;i&65536;i++)v[i]=v[i&&1]+(i&1);
freopen("bit-squares.in","r",stdin); freopen("bit-squares.out","w",stdout);
while(~scanf("%lld", &n))
LL len = 0;
int one = 0;
one += n & 1;
LL bott = 1ll && (len - 1);
int bot = sqrt(bott) + 0.;
LL topp = (1ll && len) - 1;
int top = sqrt(min(topp, (LL)1e18));
//printf("%lld %lld\n", bott, topp);
//printf("%d %d\n", bot, top);
int ans = 0;
LL val = (LL)bot * bot, add = bot * 2 + 1;
for(;i+4&=i+=4){
if(popcount(val) == one)++
val += add, add += 2;
if(popcount(val) == one)++
val += add, add += 2;
if(popcount(val) == one)++
val += add, add += 2;
if(popcount(val) == one)++
val += add, add += 2;
for(; i &= ++i, val += add, add += 2)
//printf("%d %lld\n", i, val);
//val = (LL)i *
if(popcount(val) == one)++
printf("%d\n", ans);
C. Chickens
状压DP求方案数。
#include&stdio.h&
#include&iostream&
#include&string.h&
#include&string&
#include&ctype.h&
#include&math.h&
#include&set&
#include&map&
#include&vector&
#include&queue&
#include&bitset&
#include&algorithm&
#include&time.h&
const int N = 3e5 + 10;
const int inf = 1e9;
int casenum,
int c[15], e[15];
int f[15][1 && 13];
int main()
freopen("chickens.in","r",stdin);
freopen("chickens.out","w",stdout);
while(~scanf("%d", &n))
for(int i = 0; i & ++i)scanf("%d", &c[i]);
for(int i = 0; i & ++i)scanf("%d", &e[i]);
memset(f, 0, sizeof(f)); f[0][0] = 1;
int top = (1 && n) - 1;
for(int i = 0; i & ++i)
for(int j = 0; j &= ++j)if(f[i][j])
for(int k = 0; k & ++k)if((~j && k & 1) && c[i] &= e[k])
f[i + 1][j | 1 && k] += f[i][j];
printf("%d\n", f[n][top]);
D. Lights at a Crossing
对于每个观察,枚举两盏红灯,由剩余时间大的向小的连权值为差值的有向边,则最小周期为这个有向图的最小环。
时间复杂度$O(n^3+mn^2)$。
#include&cstdio&
const int N=30,inf=;
int n,m,i,j,k,f[N][N],a[N],ans=char s[99];
inline void up(int&x,int y){x&y?(x=y):0;}
int main(){
scanf("%d%d",&n,&m);
for(i=1;i&=n;i++)for(j=1;j&=n;j++)f[i][j]=
while(m--){
for(i=1;i&=n;i++){
scanf("%s",s);
if(s[0]=='X')a[i]=-1;else sscanf(s,"%d",&a[i]);
for(i=1;i&=n;i++)if(~a[i])for(j=i+1;j&=n;j++)if(~a[j]){
if(a[i]&a[j])up(f[i][j],a[j]-a[i]);
if(a[i]&a[j])up(f[j][i],a[i]-a[j]);
for(k=1;k&=n;k++)for(i=1;i&=n;i++)for(j=1;j&=n;j++)up(f[i][j],f[i][k]+f[k][j]);
for(i=1;i&=n;i++)up(ans,f[i][i]);
if(ans==inf)ans=-1;
printf("%d",ans);
E. Decimal Form
法雷序列求两分数之间分母最小的分数。
时间复杂度$O(T\log w)$。
#include&cstdio&
#include&iostream&
#include&algorithm&
#include&cmath&
#include&cstring&
typedef __int128
typedef pair&lll,lll&P;
lll n,r,a,b,c,d,t;
const int lim=;
const ld eps=1e-15;
lll gcd(lll a,lll b){return b?gcd(b,a%b):a;}
P cal(lll a,lll b,lll c,lll d){
lll x=a/b+1;
if(x*d&c)return P(x,1);
if(!a)return P(1,d/c+1);
if(a&=b&&c&=d){
P t=cal(d,c,b,a);
swap(t.first,t.second);
P t=cal(a-b*x,b,c-d*x,d);
t.first+=t.second*x;
void write(lll x){
if(x&=10)write(x/10);
printf("%d",(int)x);
//0.666667
int main(){
freopen("decimal-form.in","r",stdin);
freopen("decimal-form.out","w",stdout);
scanf("%d",&Case);
while(Case--){
static char s[100];
scanf("%s",s);
int len=strlen(s);
for(int i=2;i&i++)r=r*10+s[i]-'0';
puts("0 1");
for(t=10;n--;t*=10);
a=r*10-5,b=t;
c=r*10+5,d=t;
lll o=gcd(a,b);
a/=o,b/=o;
o=gcd(c,d);
c/=o,d/=o;
P p=cal(a,b,c,d);
if(b&p.second)p=P(a,b);
write(p.first);
putchar(' ');
write(p.second);
F. Martian Maze
G. Wet Mole
Floodfill求出所有水能灌到的点即可。
时间复杂度$O(nm)$。
#include&cstdio&
const int N=1010;
int n,m,i,j,char a[N][N];bool v[N][N];
inline bool check(int x,int y){
if(x&1||x&n||y&1||y&m)return 0;
if(a[x][y]=='#')return 0;
void dfs(int x,int y){
if(v[x][y])
v[x][y]=1;
if(check(x+1,y))dfs(x+1,y);
if(check(x,y-1))dfs(x,y-1);
if(check(x,y+1))dfs(x,y+1);
int main(){
freopen("mole.in","r",stdin);
freopen("mole.out","w",stdout);
scanf("%d%d",&n,&m);
for(i=1;i&=n;i++)scanf("%s",a[i]+1);
for(i=1;i&=m;i++)if(a[1][i]=='.')dfs(1,i);
for(i=1;i&=n;i++)for(j=1;j&=m;j++)if(a[i][j]=='.'&&!v[i][j]){
if(!flag){
a[i][j]='X';
puts("Yes");
for(i=1;i&=n;i++)puts(a[i]+1);
}else puts("No");
H. Oddities
I. Sorting on the Plane
将所有向量分成两类:在$1$号向量左侧和右侧的。然后分别排序即可。
时间复杂度$O(n\log n)$。
#include&cstdio&
#include&algorithm&
#include&vector&
const int N=100010;
int n,i,f[N],m,t;
vector&int&q[2];
int ask(int x,int y){
printf("? %d %d\n",x,y);
fflush(stdout);
scanf("%d",&t);
bool cmp(int x,int y){return ask(x,y);}
int main(){
scanf("%d",&n);
puts("! YES");
puts("1");
fflush(stdout);
for(i=2;i&=n;i++){
q[ask(1,i)].push_back(i);
for(i=0;i&2;i++)sort(q[i].begin(),q[i].end(),cmp);
for(i=0;i&q[0].size();i++)f[++m]=q[0][i];
for(i=0;i&q[1].size();i++)f[++m]=q[1][i];
if(t=ask(f[1],f[m]))puts("! YES");else puts("! NO");
if(!t)printf("%d ",m);
for(i=1;i&=m;i++)printf("%d ",f[i]);
fflush(stdout);
J. Center of List of Sums
二分求出上下界以及上下界的排名,然后将中间的数暴力取出即可。
时间复杂度$O(n\log n)$。
#include&cstdio&
#include&algorithm&
const int N=2000010;
int n,m,i;ll a[N],b[N],q[N],L,R,down,up,cntdown,
inline ll cal(ll lim){//&=lim
int i=1,j=n;
for(i=1;i&=n;i++){
while(j&&a[i]+b[j]&lim)j--;
inline ll getkth(ll k){
ll l=0,r=,mid,t;
while(l&=r){
mid=(l+r)&&1;
if(cal(mid)&=k)r=(t=mid)-1;else l=mid+1;
void push(ll A,ll B){
int i,j=n,k=n;
for(i=1;i&=n;i++){
while(j&&a[i]+b[j]&=A)j--;
while(k&&a[i]+b[k]&B)k--;
for(int o=j+1;o&=k;o++)q[++m]=a[i]+b[o];
int main(){
freopen("sums-center.in","r",stdin);
freopen("sums-center.out","w",stdout);
scanf("%d",&n);
for(i=1;i&=n;i++)scanf("%lld",&a[i]);
for(i=1;i&=n;i++)scanf("%lld",&b[i]);
sort(a+1,a+n+1);
sort(b+1,b+n+1);
L=1LL*n*(n-1)/2+1;
R=1LL*n*(n+1)/2;
down=getkth(L);
up=getkth(R);
//printf("L=%lld R=%lld down=%lld up=%lld\n",L,R,down,up);
if(down==up){
for(ll o=L;o&=R;o++)printf("%lld ",down);
cntdown=cal(down);//&=down
cntup=cal(up-1);//&up
//printf("cnt=%lld %lld\n",cntdown,cntup);
push(down+1,up-1);
for(ll o=L;o&=cntdown&&o&=R;o++)q[++m]=
for(ll o=R;o&cntup&&o&=L;o--)q[++m]=
sort(q+1,q+m+1);
for(i=1;i&=m;i++)printf("%lld ",q[i]);
K. Cookies
将每个串排序,然后直接DP求出最长链即可。
#include&cstdio&
#include&string&
#include&algorithm&
#include&map&
#include&iostream&
const int N=180000;
int n,m,i;
int len[N];
int f[N],g[N];
string name[N],show[N],need[N];
map&string,int&
string q[N];
int dp(int x){
if(!x)return 0;
if(f[x])return f[x];
int A=f[x],B=0;
for(int i=0;i&name[x].size();i++){
string now=name[x];
now.erase(i,1);
int o=pos[now];
int t=dp(o);
if(t&A)A=t,B=o;
f[x]=A+1,g[x]=B;
return f[x];
int main(){
freopen("word-chains.in","r",stdin); freopen("word-chains.out","w",stdout);
cin&&n;//n=10000
for(i=0;i&n;i++)cin&&need[i];
cin&&m;//173554
name[1]="";
show[1]=".";
for(i=2;i&=m;i++){
cin&&name[i];
show[i]=name[i];
for(i=1;i&=m;i++){
sort(name[i].begin(),name[i].end());
pos[name[i]]=i;//sorted
len[i]=name[i].size();
for(i=0;i&n;i++){
string now=need[i];
sort(now.begin(),now.end());
int x=pos[now];
int cnt=0;
q[++cnt]=show[x];
q[1]=need[i];
cout&&cnt&&
for(int j=1;j&=j++){
cout&&q[j];
if(j&cnt)cout&&" -& ";else cout&&
university
university
L. Xor-fair Division
若所有数异或和非$0$,则答案为$0$,否则答案为$2^n-2$。
#include&cstdio&
long long ans,sum,x;
int main(){
freopen("xorseq.in","r",stdin);
freopen("xorseq.out","w",stdout);
scanf("%d",&n);
ans=1LL&&n;
while(n--){
scanf("%lld",&x);
if(sum)ans=0;
else if(n==1)ans=0;
else ans-=2;
printf("%lld",ans);
阅读(...) 评论()New York Personal Injury Lawyer | David I. Pankin P.C.
PERSONAL INJURYWhen people hear the phrase “personal injury” they usually think only of trip and fall accidents and car accidents, but we can help you with wide variety of cases.MEDICAL MALPRACTICEMedical malpractice occurs when a medical care provider or facility deviates from the accepted reasonable standard of care within the medical community.PRODUCT LIABILITYIf a person is seriously injured or killed by a defective product, the designer, manufacturer, supplier, and/or retailer may be held liable for damages.WORKERS COMPBeing injured on the job can be difficult. If you have been injured while on the job, we can help you seek the&maximum compensation for your injuries.Call Today For A Free ConsultationNew York Personal Injury and Medical Malpractice AttorneyThe Law Offices of David I. Pankin, P.C. is a personal injury law firm with a strong reputation for providing personalized attention and dedicated counsel.Our goal is to provide every client with the compassionate service and get them the monetary results that they deserve. We spend time getting to know each of our client’s cases and respond quickly to any questions or concerns our clients might have.We never charge a fee in a personal injury action unless there is a financial recovery for our client.We are dedicated to protecting the rights of the New York accident victims!To speak with an experienced personal injury attorney today, fill out our easy online contact form or call 888-529-9600.Remember, We only get paid if when we win.reviews WATCH OUR VIDEOSPersonal Injury and Medical Malpractice Videos&&
PRACTICE AREASRepresenting Real People, Getting Real ResultsOur team handles a wide variety of cases including but not limitted to personal injury, medical malpractice, product liability, and workers compensation. ...Our CommitmentWe&Only Get Paid If We WinWe are a contingent based personal injury law firm which means, we only get paid if we win. Our team will do whats necessary to insure our clients receive fair compensation and justice for their injuries. ...Client Reviews&&
Mr. Pankin really helped me out when I didn’t know what to do... The staff was always pleasant and very helpful. Everything was always explained and they answered any questions no matter how many times I called.
David Pankin represented me... I found him and his staff so pleasant and thorough and I would highly recommend him
My experience with The Law Firm of David I Pankin was very satisfying. I can't say enough about him and his entire legal team, I highly recommend The Law Office of David I Pankin, for your legal problems.
I would have to say that working with David I. Pankin and his team was a huge pleasure. In the beginning, I was very anxious of any outcome, but they were there for me all the way and they embraced me with confidence, trust and guidance. With their expertise and hard work it resulted to a 100% success in every aspect. Thank you Mr. Pankin for all of your help and a special thanks to Robert, Zaira and Fernando. I HIGHLY RECOMMEND THE LAW OFFICE OF DAVID I. PANKIN.
The Law Offices of David I. Pankin P.C. was not only knowledgeable but they were caring. The Law Offices of David I. Pankin P.C. has assured me that they are always available for me to speak with and consult with should I have additional questions or concerns. I heartily recommend the Law offices of David I. Pankin P.C. They are pleasant, confident, and professional in all ways. I recommend them without any reservation.
&Personal Injury Blog&&
According to a number of recent studies there is a type of accident that is becoming more and more prevalent, pedestrian accidents caused by using a smartphone while walking. Much attention has been paid to...
There are three blood thinners currently on the market, Xarelto, Pradaxa and Eliquis that have been receiving attention due to their aggressive marketing by pharmaceutical companies and frequent television commercials from national personal injury firms....
&Awards & Memberships
A Consumer Reports study has found that a low credit score can cost a driver hundreds of dollars a year in... In “a cautionary tale for the countless young professional athletes who currently have the world at their feet”... Here is our most recent debt relief ad. Watch it now.
https://t.co/o88kYhsVhB Watch our latest Personal Injury Video!
https://t.co/zPtBUsNxj7
New York City
49 West 37th Street7th Floor
New York, NY 10018 Tel: 212-465-0860
Fax: 212-465-0820
48 Willoughby Street 2nd FloorBrooklyn, NY 11201 Tel: 718-243-2444
Fax: 718-243-1144
Long Island
68 S Service Rd #100
Melville, NY 11747 Tel: 631-870-4269
Fax: 718-243-1144
The Law Offices of David I. Pankin, P.C. provides bankruptcy, foreclosure and loan modification representation to clients throughout the New York area in boroughs that include Manhattan, Brooklyn, Long Island, Queens, Bronx and Staten Island. This website is a Legal Advertisement. We are a debt relief agency. We help people file for bankruptcy relief under the bankruptcy code. The information on this website is for general information purposes only. Nothing on this site should be taken as legal advice for any individual case or situation. This information is not intended to create, and receipt or viewing does not constitute an attorney client relationship.}

我要回帖

更多关于 火影战记 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信