暑期集訓第一場

2021-09-25 11:02:45 字數 3926 閱讀 2480

找規律,當n%3 == 0的時候,ans=pow(n/3,3),當n%4==0的時候,就是pow(n/2,2)*n/4。

#include

#include

#define ll long long

using

namespace std;

ll t,n;

intmain()

else

if(n%4==

0)else

}}

題目中說了不會三條邊一條直線,所以就直接按照從左下到右上的規律排起來,然後直接三個一排輸出就行了。

#include

#include

#include

#define ll long long

using

namespace std;

int t,n;

const

int maxn =

1e5;

struct nodea[maxn]

;bool

cmp(node tx,node ty)

intmain()

sort

(a,a+

3*n,cmp)

;int pos=0;

for(

int i=

0;i<

3*n;i++)}

}}

就直接模擬就行了,要注意double直接轉換int可能導致丟失精度,所以先round一下。

#include

#include

#include

#include

#include

using

namespace std;

int n;

int h,m;

double k;

char c;

const

int maxn =20;

intmain()

scanf

("%lf"

,&k)

;//if(k<0)k*=-1;

int a=k;

//int b = 60*(k-(double)a+0.05);

k-=(

int)k;

double b =

round

((k+

0.001)*

60);//cout<<"b: "(c==

'-')

h=h+a-8;

m+=b;if

(m>=60)

if(h>=24)

if(m<0)

if(h<0)

printf

("%02d:%02d\n"

,h,m);}

}

直接用set模擬,先把1->maxn的數insert進set,然後把x,y排序,x,y小的排前面,然後就直接從小到大,l出範圍的erase掉,r進的放入set.begin()。

#include

#include

#include

#include

#include

#include

#include

using

namespace std;

const

int maxn =

1e5+

500;

int a[maxn]

;int n,m,t,l,r;

struct nodeb[maxn]

;bool

cmp(node x,node y)

intmain()

for(

int i=

0;i)sort

(b,b+m,cmp)

;int pos=0;

for(

int i=

0;i)continue;}

else

else

if(b[i]

.l<=b[pos]

.r)}

else}}

}}for(

int i=

1;i<=n;i++)}

}

結論:有乙個左括號,那麼當有乙個右括號的時候就一定是匹配的,所以讀入的時候可以把匹配的去掉就變成了,)))(((這種形式的剩餘的字串,然後就給這些字串進行排序。排序的方式是關鍵,當左括號數量大於右括號時,再比誰的右括號少。當左括號數量小於右括號時,再比誰的右括號數量多。

#include

#include

#include

#include

#include

using

namespace std;

const

int maxn=

1e5+

500;

char c[maxn]

;int t,n;

struct nodea[maxn]

;bool

cmp(node x,node y)

if(x.left<=x.right)

}int

main()

else

++r;

} a[i]

.left=l;

a[i]

.right=r;

a[i]

.num=l-r;

a[i]

.sum=l+r;

a[i]

.p=(

double

)l/(

double

)(l+r);}

sort

(a,a+n,cmp)

; l=r=0;

for(

int i=

0;i(a[i]

.right>=l)

else

l+=a[i]

.left;

} cout<}}

找規律:實在是找不出來規律,看大佬找的規律是,具有相同lowbit的數出現的次數均為log(lowbit(x)+1)。

問題就是變成了求幾個等差數列的和。

#include

using

namespace std;

const

int maxn =

100;

const

int mod =

1e9+7;

long

long p[maxn]

,num[maxn]

,n;long

long inv=

(mod+1)

/2;//2的逆元,不用逆元目測會炸

intlowbit

(int x)

intgetamo

(long

long x)

//獲得出現的次數

long

long

solve

(long

long x)

return

(ans+1)

%mod;

}int

main()

long

long tmp=n,sum=0;

for(

int i=

62;i>=

0;i--)if

(tmp>=num[i]

) tmp-

=num[i]

,sum+

=p[i]

;long

long ans=

solve

(sum);if

(tmp)

printf

("%lld\n"

,ans);}

}return0;

}

暑期第一場題解

此題,emmmm,有毒,很容易出現各種bug,還是自己菜,不能動不動就覺得是資料有問題,此題肯定要用字串,模擬的題,有點長 蒟蒻瑟瑟發抖 不過不難理解,仔細看看就明白了,主要是細節方面的處理 include include include includeusing namespace std int...

acm暑期第一場比賽總結

打的時候心態真的很重要,特別是對於我這樣的新手,比賽的時候,乙個簡單的二分,還有乙個對於我稍複雜的模擬,寫到心態 思路混亂,再加上趕著交題,連a題這樣水爆了的題都wa了一次,還有英語的問題,習慣了掛翻譯,讀不懂題目意思,就開始動手寫,這是不科學的。場下補完了b,d題,d題dfs 剪枝,b就是wa爆了...

暑假集訓 個人賽第一場

g qin shi huang s national road system 題意是給你平面上n個點,每個點代表乙個城市,給你每個城市的人口,修n 1條路讓其連通。有法術可以讓其中免去其中一條路的費用。讓你求是的a b最大的時候的最小花費,其中a是免費的這條路連線的兩個城市的人口之和,b是需要花費的...