2012天津網路賽的1004

2021-06-09 06:50:16 字數 2026 閱讀 6129

本來以為有什麼好方法的,初看感覺是網路流可是不知道怎麼建圖,然後sphinx和我說可能是狀態壓縮,但是我狀態壓縮的複雜度有點高,是2的30次方,絕對超時,然後覺得這題實在想不出來去網上搜了一下發現真的有人用狀態壓縮過了,覺得有點不可思議,我敲了一下沒想到也過了。。。c++的輸入輸出無任何優化156ms1y,有點假,這難道就是昨天那麼多隊水過這題的原因嗎。。。

#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;

#ifdef _win32

#define i64 __int64

#define out64 "%i64d\n"

#define in64 "%i64d"

#else

#define i64 long long

#define out64 "%lld\n"

#define in64 "%lld"

#endif

/************ for topcoder by zz1215 *******************/

#define for(i,a,b) for( int i = (a) ; i <= (b) ; i ++)

#define fff(i,a) for( int i = 0 ; i < (a) ; i ++)

#define ffd(i,a,b) for( int i = (a) ; i >= (b) ; i --)

#define s64(a) scanf(in64,&a)

#define ss(a) scanf("%d",&a)

#define ll(a) ((a)<<1)

#define rr(a) (((a)<<1)+1)

#define pb push_back

#define max(a,b) ((a)>(b)?(a):(b))

#define min(a,b) ((a)<(b)?(a):(b))

#define cl(q) while(!q.empty())q.pop()

#define mm(name,what) memset(name,what,sizeof(name))

#define read freopen("in.txt","r",stdin)

#define write freopen("out.txt","w",stdout)

const int inf = 0x3f3f3f3f;

const i64 inf64 = 0x3f3f3f3f3f3f3f3fll;

const double oo = 10e9;

const double eps = 10e-9;

const double pi = acos(-1.0);

const int maxn = 22;

const int maxs = 1<<16;

int w[maxs+1];

int f[maxs+1];

int n,m;

int way[maxn][maxn];

int x[maxn];

int y[maxn];

int c[maxn];

int dp[maxs+1];

vectorv;

int bt(int x)

int getway(int a,int b)

void dfs(int tot,int s,int now=0,int cost=0,int x=0,int step=0)

else

else

for(int i=0;i>c[i];

if(c[i]>m)

}if(ok == false)

{ cout<<"-1 -1"<

HDU4279 2023年天津網路賽

題意 給出乙個f x 表示不大於x的正整數裡,不整除x且跟x有大於1的公約數的數的個數。定義f x 為不大於x的正整數裡,滿足f x 的值為奇數的數的個數。題目就是求這個f x 網上很多方法就是打表找規律,已經談不上是演算法了。這裡我們可以來分析 不整除x且跟x有大於1的公約數的數的個數 f x x...

敏捷之旅2012天津站活動組織心得

今年2012,是天津軟體本地社群的第二次舉辦敏捷之旅活動。去年的破冰之旅還歷歷在目,經過一年的時間,天津有更多的朋友開始接觸敏捷,實踐敏捷,討論敏捷,並加入軟體社群積極參加和回饋,也使得天津軟體行業更加繁榮和具有競爭力。今年共有四位組織者 eugene xerox king費事 申導 柴阿峰 大家 ...

fzyzojP1876 天津 泥人張

思路一 考慮lucas定理,mod 4意義下,每乙個組合數都不能是0 所以,把n變成 制數,然後數字dp即可 f i 0 1 0 1 2 3 表示,前i位,有沒有限制,mod 4 的值是0 1 2 3 發現,4 2 2,所以如果出現乙個0或者兩個2都可以 所以,簡化一下 f i 0 1 0 1 2 ...