30分剩下超时求优化
查看原帖
30分剩下超时求优化
1567838
Likang123456楼主2024/12/12 19:38

代码如下

#include<stdio.h>
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    int temp=0,ans=0;
    for(int x1=0;x1<n;x1++){
        for(int y1=0;y1<m;y1++){
            for(int x2=0;x2<=n;x2++){
                for(int y2=0;y2<=m;y2++){
                    if(x2>x1&&y2>y1){
                        if((x2-x1)==(y2-y1)){
                            temp++;
                        }
                        else ans++;
                    }
                }
            }
            
        }
    }
    printf("%d ",temp);
    printf("%d",ans);
    return 0;}
2024/12/12 19:38
加载中...