#include<bits/stdc++.h>
using namespace std;
int main(){
freopen("p1725.in","r",stdin);
freopen("p1725.out","w",stdout);
int n,i,j,k,a[11][11]={0};
cin>>n;
for(k=1;k<=n;k++) {
for(j=1;j<=n+1-k;j++)a[n+1-k][j]=k;
for(i=1;i<=n+1-k;i++)a[i][n+1-k]=k;
}
for(i=1;i<=n;i++){
for(j=1;j<=n;j++)cout<<setw(3)<<a[i][j];
cout<<endl;
}
fclose(stdin);
fclose(stdout);
return 0;
}
#include <iostream>
using namespace std;
int main() {
freopen("p1051.in","r",stdin);
freopen("p1051.out","w",stdout);
int n, x;
cin >> n >> x;
int count= 0 ;
int score;
for (int i = 0; i < n; i++) {
cin >> score;
if (score > x) {
count++;
}
}
cout << count + 1 << endl;
fclose(stdin);
fclose(stdout);
return 0;
}
#include <iostream>
using namespace std;
int main() {
freopen("p1047.in","r",stdin);
freopen("p1047.out","w",stdout);
int n;
cin >> n;
int triangle[n][n];
int num = 1;
for (int col = 0; col < n; col++) {
for (int row = col; row < n; row++) {
triangle[row][col] = num++;
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j <= i; j++) {
if (j > 0) cout << " ";
cout << triangle[i][j];
}
cout << endl;
}
fclose(stdin);
fclose(stdout);
return 0;
}
#include <iostream>
using namespace std;
int main() {
freopen("p1031.in","r",stdin);
freopen("p1031.out","w",stdout);
long long n;
cin >> n;
long long left = 1, right = 1e9;
while (left < right) {
long long mid = (left + right) / 2;
if (mid * mid >= n) {
right = mid;
} else {
left = mid + 1;
}
}
cout << 2 * left << endl;
fclose(stdin);
fclose(stdout);
return 0;
}
( ) |