2018ICPC南京Problem G. Pyramid
题意:
询问类似于这样的三角形中:
里面正三角形的个数是多少。
思路:
打表找了个规律发现就是C4n+3

1 //#include<bits/stdc++.h>
2 #include<time.h>
3 #include <set>
4 #include <map>
5 #include <stack>
6 #include <cmath>
7 #include <queue>
8 #include <cstdio>
9 #include <cstring>
10 #include <string>
11 #include <vector>
12 #include <cstring>
13 #include <iostream>
14 #include <algorithm>
15 #include <list>
16 using namespace std;
17 #define mem(s,n) memset(s,n,sizeof s);
18 #define ios {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
19 #define pai 3.141592653589793238462643383279502884197169
20 typedef long long ll;
21 typedef unsigned long long ull;
22 const int maxn=1e2+1;
23 const int Inf=0x7f7f7f7f;
24 const ll Mod=1e9+7;
25 const int N=3e3+5;
26 bool isPowerOfTwo(int n) { return n > 0 && (n & (n - 1)) == 0; }//判断一个数是不是 2 的正整数次幂
27 int modPowerOfTwo(int x, int mod) { return x & (mod - 1); }//对 2 的非负整数次幂取模
28 int getBit(int a, int b) { return (a >> b) & 1; }// 获取 a 的第 b 位,最低位编号为 0
29 int Max(int a, int b) { return b & ((a - b) >> 31) | a & (~(a - b) >> 31); }// 如果 a>=b,(a-b)>>31 为 0,否则为 -1
30 int Min(int a, int b) { return a & ((a - b) >> 31) | b & (~(a - b) >> 31); }
31 ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
32 ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
33 int Abs(int n) {
34 return (n ^ (n >> 31)) - (n >> 31);
35 /* n>>31 取得 n 的符号,若 n 为正数,n>>31 等于 0,若 n 为负数,n>>31 等于 -1
36 若 n 为正数 n^0=n, 数不变,若 n 为负数有 n^(-1)
37 需要计算 n 和 -1 的补码,然后进行异或运算,
38 结果 n 变号并且为 n 的绝对值减 1,再减去 -1 就是绝对值 */
39 }
40 ll binpow(ll a, ll b,ll c) {
41 ll res = 1;
42 while (b > 0) {
43 if (b & 1) res = res * a%c;
44 a = a * a%c;
45 b >>= 1;
46 }
47 return res%c;
48 }
49 void extend_gcd(ll a,ll b,ll &x,ll &y)
50 {
51 if(b==0) {
52 x=1,y=0;
53 return;
54 }
55 extend_gcd(b,a%b,x,y);
56 ll tmp=x;
57 x=y;
58 y=tmp-(a/b)*y;
59 }
60 ll mod_inverse(ll a,ll m)
61 {
62 ll x,y;
63 extend_gcd(a,m,x,y);
64 return (m+x%m)%m;
65 }
66 int main()
67 {
68 ll T,n;
69 scanf("%lld",&T);
70 while(T--){
71 scanf("%lld",&n);
72 ll sum=1;
73 for(int i=0;i<=3;i++)
74 {
75 sum=sum*(n+i)%Mod;
76 }
77 ll k=mod_inverse(24,Mod);
78 sum=((sum%Mod)*(k%Mod))%Mod;
79 printf("%lld\n",sum);
80 }
81 return 0;
82 }
2018ICPC南京Problem G. Pyramid的更多相关文章
- 2018icpc南京/gym101981 G Pyramid 找规律
题意: 数一个金字塔里面有多少个正三角形. 题解: ans[n]=n*(n-1)*(n-2)*(n-3)/24 #include<bits/stdc++.h> using namespac ...
- 2018ICPC南京站Problem G. Pyramid
题意: 找有多少个等边三角形 解析: 首先打标找规律,然后对式子求差分 0,1,5,15,35,70,126,210... 1,4,10,20,35,56... 3,6,10,15,21... 3,4 ...
- 2018ICPC 南京Problem J. Prime Game
题目: 题意:给出一个序列a1,⋯,ana1,⋯,an.fac(l,r)fac(l,r)为mul(l,r)mul(l,r)中不同质因数的个数. 请计算: ∑i=1n∑j ...
- 2018ICPC南京网络赛
2018ICPC南京网络赛 A. An Olympian Math Problem 题目描述:求\(\sum_{i=1}^{n} i\times i! \%n\) solution \[(n-1) \ ...
- 实验9:Problem G: 克隆人来了!
想要输出""的话: cout<<"A person whose name is \""<<name<<" ...
- 实验12:Problem G: 强悍的矩阵运算来了
这个题目主要是乘法运算符的重载,卡了我好久,矩阵的乘法用3个嵌套的for循环进行,要分清楚矩阵的乘法结果是第一个矩阵的行,第二个矩阵的列所组成的矩阵. 重载+,*运算符时,可以在参数列表中传两个矩阵引 ...
- 烟大 Contest1024 - 《挑战编程》第一章:入门 Problem G: Check The Check(模拟国际象棋)
Problem G: Check The Check Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 10 Solved: 3[Submit][Statu ...
- The Ninth Hunan Collegiate Programming Contest (2013) Problem G
Problem G Good Teacher I want to be a good teacher, so at least I need to remember all the student n ...
- 【贪心+中位数】【新生赛3 1007题】 Problem G (K)
Problem G Time Limit : 4000/2000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Sub ...
随机推荐
- Netty(五)Netty 高性能之道
4.背景介绍 4.1.1 Netty 惊人的性能数据 通过使用 Netty(NIO 框架)相比于传统基于 Java 序列化+BIO(同步阻塞 IO)的通信框架,性能提升了 8 倍多.事 实上,我对这个 ...
- 牛客多校第三场J LRU management(双向链表)题解
题意: 给一个长度为\(m\)的队列,现给定以下操作: \(opt=0\),插入一个串,如果不在队里直接插入栈尾,如果超出\(m\)删队首:在队里就拿出来重新放到队尾,返回\(v\)值. \(opt= ...
- Deep Learning Specialization 笔记
1. numpy中的几种矩阵相乘: # x1: axn, x2:nxb np.dot(x1, x2): axn * nxb np.outer(x1, x2): nx1*1xn # 实质为: np.ra ...
- vue 如何重绘父组件,当子组件的宽度变化时候
vue 如何重绘父组件,当子组件的宽度变化时候 vue & dynamic el-popover position demo https://codepen.io/xgqfrms/pen/wv ...
- Flutter Search Component
Flutter Search Component flutter 搜索组件 xgqfrms 2012-2020 www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
- SVG & getBBox
SVG & getBBox https://developer.mozilla.org/en-US/docs/Web/API/SVGGraphicsElement/getBBox const ...
- jquery.query.js
帮助文档 var url = location.search; > "?action=view§ion=info&id=123&debug&te ...
- 「NGK每日快讯」2021.1.22日NGK公链第80期官方快讯!
- java中的桥接方法
本文转载自java中什么是bridge method(桥接方法) 导语 在看spring-mvc的源码的时候,看到在解析handler方法时,有关于获取桥接方法代码,不明白什么是桥接方法,经过查找资料 ...
- java自学第4期——:Scanner类、匿名对象介绍、Random类、ArrayList集合、标准类格式、String类、static静态、Arrays工具类、Math类(1)
一.Scanner类 1.api简介: 应用程序编程接口 2.Scanner类: 作用:获取键盘输入的数据 位置: java.util.Scanner. 使用:使用成员方法nextInt() 和 ne ...