zju 1037 Gridland(找规律,水题)】的更多相关文章

题目链接 多写几个案例,根据数据的奇偶性,就能找到规律了 #include<stdio.h> int main() { int t,n,m; double ans; scanf("%d",&t); ;i<=t;i++) { scanf("%d%d",&n,&m); ans=n*m*1.0; ==&&m%==) ans+=0.41; printf("Scenario #%d:\n%.2lf\n\n&q…
题目 链接 题意:给出x数列的定义: $T_0 = a$ $T_1 = b$ $T_n = T_{n-2} \bigoplus T_{n-1} $ 求第 $n$ 项( $0 \leqslant a,b,c \leqslant 10^{18} $) 分析 $n$ 这么大,肯定是常数时间复杂度. 打表找规律,能发现循环节为3. 或者直接推导,$a \bigoplus b = c, \ b \bigoplus c = a, \ c \bigoplus a = b$ #include<bits/stdc…
题目链接: http://codeforces.com/gym/101194/attachments https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5919 题意: 给出正整数 $N(1 \le N \le 10^5)$,询问对于正整数 $k$,有多少个小于 $2^N$ 的 $2^k-1$ 是 $7$ 的整数倍. 题解: $…
A. Little Pony and Expected Maximum Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/453/problem/A Description Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing.…
代码: #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> using namespace std; int main() { int h,m,s; int h0,m0,s0; while(scanf("%d.%d.%d%d.%d.%d",&h0,&m0,&s0,&h,&m,&s)!=EOF) {…
题意:给出一棵二分搜索树,再给一个节点编号n,求以这个节点为根节点的子树叶子节点的最大值与最小值. 首先求n所在的层数,他的层数就是他的因子中2的个数(规律). n的左右各有num=2^i-1个数.最小值是n-num,最大值是n+num #include <iostream> #include <algorithm> #include <stdio.h> #include <string.h> #include <queue> using nam…
分析:给出一个矩阵.问最短从一个点经过全部点以此回到起点的长度是多少.绘图非常好理解.先画3*4.3*3.4*4的点阵图案.试着在上面用最短路走一走,能够发现当矩形点阵的长宽都是奇数时,最短路中必然有一条斜线:而仅仅要长或宽有一个是偶数就能够通过直线来完毕最短路经.因此仅仅需推断一下两边的奇偶情况就能求最短路径了. #include<iostream> #include<cmath> using namespace std; int main() { int T,t=0,m,n;…
已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现是找规律的题了= =都是2的n-1次方,而且这题输出二进制数就行了......那就更简单了,直接输出1,然后后面跟n-1个0就行了╮(╯_╰)╭ 下面AC代码 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm>…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1245 题意就是求 n/i (1<=i<=n) 的取整的和这就是到找规律的题, i     1  2   3   4   5   6   7    8 a    8  4   2   2   1   1   1    1 你可以多写几组你会发现 有8-4个1:4-2个2:...其他例子也是这样: 当n = 10时 n/1 = 10, n/2 = 5说明(5, 10]这个前开后闭的区间…
[BZOJ1432][ZJOI2009]Function(找规律) 题面 BZOJ 洛谷 题解 这...找找规律吧. #include<iostream> using namespace std; int n,k; int main() { cin>>n>>k;k=min(k,n-k+1); cout<<(n==1?1:k<<1)<<endl; return 0; }…