hdu5047(上海网赛1006)Sawtooth

   题意:一个矩形画布。在上面画“M”,问画n个M,最多把画布分为几部分。

        思路:找规律,研究画第二个M的时候,在第一个的基础上增加了多少区域。可以得出公式:16*n*(n-1)/2+2+n-1。然后因为结果爆long long,高精度搞超时,所以砍半来计算。


#include <stdio.h>
#include <string.h> 
#include <stdlib.h> 
#include <math.h>
#include <assert.h>  
#include <ctype.h> 
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <utility>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <iostream>
#include <fstream>
#include <list>
using  namespace  std;      

#define ll __int64

int main(){
    ll n;
    int t;
    cin>>t;
    int cas=0;
    while(t--){
        cas++;
        scanf("%I64d",&n);
        ll p1=(8*n)%1000000;
        ll p2=8*n/1000000;
        ll ap1=p1*(n-1)+1+n;
        ll ap2=p2*(n-1);
        
        ap2+=ap1/1000000;
        ap1%=1000000;
        
        printf("Case #%d: ",cas);
        if(ap2){
            printf("%I64d%06I64d\n",ap2,ap1);
        }else{
            printf("%I64d\n",ap1);
        }

    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值