当前位置: 代码迷 >> 综合 >> Contest3196 - 2021级新生个人训练赛第46场_E: Bichrome Cells
  详细解决方案

Contest3196 - 2021级新生个人训练赛第46场_E: Bichrome Cells

热度:47   发布时间:2023-12-06 05:25:44.0

//
问题 E: Bichrome Cells
时间限制: 1.000 Sec  内存限制: 128 MB题目描述
We have an N×N square grid.
We will paint each square in the grid either black or white.
If we paint exactly A squares white, how many squares will be painted black?Constraints
1≤N≤100
0≤A≤N^2
输入
Input is given from Standard Input in the following format:
N
A
输出
Print the number of squares that will be painted black.
样例输入 Copy
3
4
样例输出 Copy
5
提示
There are nine squares in a 3×3 square grid. 
Four of them will be painted white, so the remaining five squares will be painted black.

//
#include<bits/stdc++.h>
using namespace std;int main()
{int n,a;while( ~scanf("%d%d",&n,&a) ){printf("%d\n",n*n-a);}return 0;
}

//
#include<bits/stdc++.h>
using namespace std;int main()
{int n,a,ans;while( ~scanf("%d%d",&n,&a) ){printf("%d\n",ans=n*n-a);}return 0;
}

  相关解决方案