二维下,如果把杨辉三角按照题目里要求的那样摆放,容易发现,第i行第j列的数(从0开始标号)是C(i+j,i)*C(j,j). 高维下也有类似规律,比如三维下,最后一层的数其实是C(i+j+k,i)*C(j+k,j)*C(k,k). 题目提示你了,坐标组合相同的位置,其值一定相同. 于是dfs最后一层的序号组合,统计答案即可.我只加了一个可行性剪枝,应该还能加一个的. #include<cstdio> #include<set> using namespace std; typede…
题意:给你一个经典的汉诺塔递归程序,问你最少几步使得三个柱子上的盘子数量相同.(保证最开始盘子数量可以被3整除) 规律:ans(n)=2^(2*n/3-1)+t(n/3). t(1)=0. t(n)= t(n-1)+1,n为偶数 t(n-1)*4+2,n为奇数. Java文件读写主要有以下两种方法,第二种,输出格式更随心所欲,更实用: import java.util.*; import java.io.*; import java.math.*; public class Main{ publ…
以后这种题还是不能空想,必须打个表看看,规律还是比较好找的……具体是啥看代码.用SG函数暴力的部分就不放了. #include<cstdio> using namespace std; int T,N,B,n; int main() { freopen("powers.in","r",stdin); scanf("%d",&T); for(;T;--T) { int ans=0; scanf("%d",&a…
semipal.in / semipal.out Por Costel the pig, our programmer in-training, has recently returned from the Petrozaporksk training camp. There, he learned a lot of things: how to boil a cob, how to scratch his belly using his keyboard, etc... He almost r…
A. Hanoi tower Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description you the conditions of this task. There are 3 pivots: A, B, C. Initially, n disks of different diameter are placed on the pivot A: the smallest dis…
BOPCTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86686#problem/D Description You invented a new chess figure and called it BOPC. Suppose it stands at the square grid at the point with coordinates …
题目链接:https://cn.vjudge.net/contest/273377#problem/C 给你 n,m,k. 这个题的意思是给你n个数,在对前m项的基础上排序的情况下,问你满足递增子序列的长度至少为n-1的排列组合的个数. 具体方法:打表找规律. 打表代码: #include<bits/stdc++.h> #include<string> #include<cstring> #include<stdio.h> using namespace s…
题目:https://cn.vjudge.net/problem/Gym-101775L PS:训练赛中被这道题折磨的不轻,和队友反复推必胜态与必败态试图推导出公式或者规律,然后推的心态逐渐失控,,,最后十分钟没辙了,队友站在一起,猜,猜一个规律出来,emmm,比赛半路中不经意听到旁边打过这场EC-final现场赛的学长说这题打表找规律,还在对面A题后讨论中听到16和偶数,嘿嘿,于是迫不得已猜规律,比赛还剩三十秒时交上去第三个规律,就,,,就A了,,,和另一位队友逗比的叫了起来,emmm,感觉r…
题面 题意:数一个n阶三角形中,有多少个全等三角形,n<=1e9 题解:拿到题想找规律,手画开始一直数漏....,最后还是打了个表 (打表就是随便定个点为(0,0),然后(2,0),(4,0),(6,0),(1,sqrt(3)),(3,sqrt(3)),(5,sqrt(3)),(2,2*sqrt(3))...)这样 然后枚举三点算 打出来1,5,15,70,126,210,330,495,715,1001,1365,1820,2380,3060,3876 队友是插值法找的,我是纯找规律的,因为看…
Exclusive or 题目链接: http://acm.hust.edu.cn/vjudge/contest/121336#problem/J Description Given n, find the value of Note: ♁ denotes bitwise exclusive-or. Input The input consists of several tests. For each tests: A single integer n (2≤n<10^500). Output…