思路:打表.wa在了16.当我发现BUG改掉的时候,又wa了. vp结束了,一看代码.卧操~check把1放在外面了.崩溃
1. 看到1e18 能打表打表
2. 规律题总是看不出规律. MDZZ
#include<bits/stdc++.h>
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
const int N=1e5+5;
const int MOD=1e9+7;
const int INF=0x3f3f3f3f;
char s[200];
int n,m,k,ans;
int a[50][50];
bool check(){
//    for(int i=1;i<=n;i++){
//        for(int j=1;j<=m;j++) printf("%d ",a[i][j]);
//        puts("");
//    }
//    printf("***********");
    ll t;
    for(int i=1;i<=n;i++){
            t=1;
        for(int j=1;j<=m;j++) t*=a[i][j];
        if(t!=k)    return false;
    }
    for(int j=1;j<=m;j++){
        t=1;
        for(int i=1;i<=n;i++) t*=a[i][j];
        if(t!=k)    return false;
    }
//    printf("GOOD\n");
    return true;
}
void dfs(int x,int y){
    if(x==n&&y==m){
        a[x][y]=1;
        if(check()) ans++;
        a[x][y]=-1;
        if(check()) ans++;
//        puts("!**********");
        return ;
    }
    for(int t=1;t<=2;t++){
        if(t==1){
            a[x][y]=1;
            int xx=x,yy=y;
            if(m==yy) yy=1,xx++;
            else    yy++;
            dfs(xx,yy);
        }
        else{
            a[x][y]=-1;
            int xx=x,yy=y;
            if(m==yy) yy=1,xx++;
            else    yy++;
            dfs(xx,yy);
        }
    }
}
int main(void){
    for(n=1;n<=5;n++){
        for(m=1;m<=5;m++){
            ans=0;
            k=-1;
            dfs(1,1);
            printf("%d %d %d\n",n,m,ans);
        }
    }
    return 0;
}
/*********
*********/
  #include<bits/stdc++.h>
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
const int N=1e5+5;
const ll MOD=1e9+7;
const int INF=0x3f3f3f3f;
ll qm(ll a,ll b){
    ll t=1;
    while(b){
        if(b&(1ll)) t=(t%MOD*a%MOD)%MOD;
        a=(a%MOD*a%MOD)%MOD;
        b>>=1ll;
    }
    return t%MOD;
}
int main(void){
    ll n,m,k;
    cin >>n>>m>>k;
//    if(n==1 || m==1){
//        cout << 1 << endl;
//        return 0;
//    }
    if(n%2==1 && m%2==0 && k==-1){
        cout <<0;return 0;
    }
    if(n%2==0 && m%2==1 && k==-1){
        cout <<0;return 0;
    }
    ll ans=qm(2,n-1)%MOD;
    ans=qm(ans,m-1)%MOD;
    cout << ans%MOD <<endl;
    return 0;
}
/*********
*********/
 
京公网安备 11010502036488号