• 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
    ",sum);
    80     }
    81    return 0;
    82 }
    View Code
  • 相关阅读:
    20180929 北京大学 人工智能实践:Tensorflow笔记02
    20180929 北京大学 人工智能实践:Tensorflow笔记01
    YOLOv3学习笔记
    编辑器上传漏洞
    IIS解析漏洞利用
    数据库备份及审查元素进行webshell上传
    burp suite 进行webshell上传
    BUGKU CFT初学之WEB
    CTFbugku--菜鸟初学
    理解PHP中的会话控制
  • 原文地址:https://www.cnblogs.com/zpj61/p/13472850.html
Copyright © 2020-2023  润新知