【2017沈阳现场】

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sxy201658506207/article/details/84673064

F

import java.math.*;
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
        Scanner cin=new Scanner(System.in);
        BigInteger aa=BigInteger.valueOf(4);
        BigInteger [] a=new BigInteger[1000];
        //a[0`]=BigInteger.valueOf(2);
        a[0]=BigInteger.valueOf(4);
        a[1]=BigInteger.valueOf(14);
        for(int t=2;t<=52;++t)
        {
            a[t]=a[t-1].multiply(aa).subtract(a[t-2]);
           // System.out.println(a[t]);
        }
        //System.out.println(a[52]);
        int t;
        t=cin.nextInt();
        for(int k=0;k<t;++k)
        {
             BigInteger val;
            val=cin.nextBigInteger();
            for(int i=0;i<=52;++i)
            {
                if(a[i].compareTo(val)>=0)
                {
                    System.out.println(a[i]);
                    break;
                }
            }
        }
    }
}

I:
 

#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <map>
#include <cstdio>
#define X 10005
#define inf 0x3f3f3f3f
#define PI 3.141592653589793238462643383
#define IO  ios::sync_with_stdio(false),cin.tie(0), cout.tie(0);
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
typedef long long ll;
typedef unsigned long long Ull;
const int maxn = (int)5*1e5 + 10;
const int MOD = 9973;//(int)1e9 + 7;
//const ll inf = 9223372036854775807;
int main()
{IO;
    int t;
    cin>>t;
    Ull a,b,c,d;
    while(t--)
    {
        cin>>a>>b>>c>>d;
        cout<<Ull(a+b+c+d)<<endl;
    }
    return 0;
}

K:

#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <map>
#include <cstdio>
#define X 10005
#define inf 0x3f3f3f3f
#define PI 3.141592653589793238462643383
#define IO  ios::sync_with_stdio(false),cin.tie(0), cout.tie(0);
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
typedef long long ll;
typedef unsigned long long Ull;
const int maxn = (int)1e5 + 10;
const int MOD = 9973;//(int)1e9 + 7;
//const ll inf = 9223372036854775807;
int a[maxn];
int b[maxn];
int main()
{
    int n,t,x,y;
    cin>>t;
    while(t--)
    {
        cin>>n;
        ll ans=0;
        for(int i=0;i<n;++i) scanf("%d",&a[i]);
        for(int i=0;i<n-1;++i) ans+=a[i+1]-a[i]-1;
        x=a[1]-a[0]-1,y=a[n-1]-a[n-2]-1;
        cout<<ans-min(x,y)<<endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/sxy201658506207/article/details/84673064