content
stringlengths 19
11k
|
---|
#include<stdio.h>
#define MOD 1000000007
#define MAX_GRID 100000
/*****memo vector for calculation n!*****/
long factorial[2*MAX_GRID];
long inverse_f[2*MAX_GRID];
long mod(long Num){
if(Num>=MOD) Num%=MOD;
return Num;
}
long inverse_element(long Num){
long inv=1;
long k=MOD-2;
while(k){
if(k&1) inv=mod(inv*Num);
Num=mod(Num*Num);
k>>=1;
}
return inv;
}
void setup(int *h, int *w, int *a, int *b){
scanf("%d %d %d %d", h, w, a, b);
factorial[0]=1;
for(int n=1; n<(*h+*w); n++){
factorial[n]=mod(n*factorial[n-1]);
}
inverse_f[*h+*w-1]=inverse_element(factorial[*h+*w-1]);
for(int n=*h+*w-1; n>0; n--) {
inverse_f[n-1]=mod(n*inverse_f[n]);
}
return;
}
long C(int n, int k){
return mod(factorial[n]*mod(inverse_f[k]*inverse_f[n-k]));
}
long sumup(int *h, int *w, int *a, int *b){
long N=0;
for(int k=1; k<=*h-*a; k++){
N += mod(C(*b+k-2, k-1) * C(*w+*h-*b-k-1, *h-k));
}
return mod(N);
}
int main(void){
int height, width, a, b;
setup(&height, &width, &a, &b);
printf("%ld\n", sumup(&height, &width, &a, &b));
return 0;
}
|
#include<stdio.h>
#include<stdlib.h>
#define MAX(x,y) (((x)>(y))?(x):(y))
const unsigned long long modnum=1E9+7;
unsigned long long invdiv(unsigned long long p);
int main(void){
unsigned long long H,W,A,B;
unsigned long long *up,*down;
unsigned long long maxnum;
unsigned long long ans,tmp;
int i,j,k;
scanf("%llu%llu%llu%llu",&H,&W,&A,&B);
maxnum=H+W;
up=(unsigned long long *)calloc(maxnum+1,sizeof(unsigned long long));
down=(unsigned long long *)calloc(maxnum+1,sizeof(unsigned long long));
up[0]=up[1]=down[0]=down[1]=1;
for(i=2;i<maxnum;i++){
up[i]=(up[i-1]*i)%modnum;
down[i]=(down[i-1]*invdiv(i))%modnum;
}
ans=0;
for(i=0;i<H-A;i++){
ans+=up[i+B-1]*down[i]%modnum*up[W-1-B+H-1-i]%modnum*down[H-1-i]%modnum;
ans%=modnum;
}
ans*=down[B-1];
ans%=modnum;
ans*=down[W-1-B];
ans%=modnum;
printf("%llu\n",ans);
return 0;
}
unsigned long long invdiv(unsigned long long p) {
unsigned long long r[3], q;
unsigned long long x[3];
div_t clc;
r[0] = p;
r[1] = modnum;
x[0] = 1;
x[1] = 0;
do {
clc = div(r[0], r[1]);
q = clc.quot;
r[2] = clc.rem;
while(x[0] < q * x[1]) x[0] += modnum;
x[2] = (x[0] - q * x[1]) % modnum;
r[0] = r[1];
r[1] = r[2];
x[0] = x[1];
x[1] = x[2];
} while(r[2] > 1);
return x[2];
}
|
long m=1e9+7,D[41][1<<17]={1};
X,i,j,k,T,M=1<<17;
main(s,n){
scanf("%d%d%d%d",&n,&j,&k,&T);
for(X=((1<<j|1)<<k|1)<<T-1;i++<n;s=s*10L%m)
for(j=k=0;k<M?:(k=0,j++<9);k++)
if(T=k+k+1<<j,~T&X)
D[i][T&=M-1]+=D[i-1][k],D[i][T]%=m;
for(;M--;)s=(s-D[n][M]+m)%m;
printf("%d",s);
}
|
long ans=1,mod=1e9+7,dp[41][1<<17];
no,i,j,k,nxt,M;
main(n,x,y,z)
{
scanf("%d%d%d%d",&n,&x,&y,&z);
no=((1|1<<x)<<y|1)<<z-1;
dp[0][0]=1;
M=1<<17;
for(;i++<n;)
{
for(j=0;j<10;j++)
{
for(k=0;k<M;k++)
{
nxt=(k+k+1<<j)&M-1;
if(~nxt&no)
{
dp[i][nxt]+=dp[i-1][k];
dp[i][nxt]%=mod;
}
}
}
ans=ans*10%mod;
}
for(;M--;)ans=(ans-dp[n][M]+mod)%mod;
printf("%d\n",ans);
}
|
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define MOD 1000000007
#define add(x,y) x=(x+y)%MOD
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
ll dp[50][1<<17];
//dp[i][j]=i文字目まで見て、XYZがなく、状態jである場合の数
//状態j=「jのx bit目が1⇔末尾から先頭に向けて見た連続部分列で和がxになるものがある」
int main(){
int n,a,b,c;
scanf("%d%d%d%d",&n,&a,&b,&c);
ll hit=((1<<a|1)<<b|1)<<c;
ll M=a+b+c;
dp[0][1]=1;
rep(i,0,n)repp(j,1,1<<M,2)rep(k,1,11)if(((j<<k)&hit)!=hit)add(dp[i+1][(j<<k|1)&((1<<M)-1)],dp[i][j]);
ll ans=0;
repp(j,1,1<<M,2)add(ans,dp[n][j]);
printf("%lld\n",(pom(10,n,MOD)-ans+MOD)%MOD);
return 0;
}
|
#include <stdio.h>
#include <string.h>
#define BMAX 16
#define MOD 1000000007
int main(void)
{
int i, j, k, n, x, y, z, xyz, mask, idx = 0, dp[2][1<<BMAX] = {0};
long res = 1;
scanf("%d %d %d %d", &n, &x, &y, &z);
xyz = (1 << (x + y + z - 1)) | (1 << (y + z - 1)) | (1 << (z - 1));
mask = ((1 << (x + y + z)) - 1) >> 1;
dp[idx][0] = 1;
for (i = 0; i < n; i++) {
memset(dp[idx^1], 0, sizeof(dp[idx^1]));
for (j = 0; j <= mask; j++) {
if (dp[idx][j] > 0) {
for (k = 0; k < 10; k++) {
int used = (j << (k + 1)) | (1 << k);
if ((used & xyz) != xyz) dp[idx^1][used&mask] = (dp[idx^1][used&mask] + dp[idx][j]) % MOD;
}
}
}
idx ^= 1;
}
for (i = 0; i < n; i++) res = (res * 10) % MOD;
for (i = 0; i <= mask; i++) res = (res - dp[idx][i] + MOD) % MOD;
printf("%ld\n", res);
}
|
c;main(a){for(;~scanf("%d",&a);)c+=a==7;puts(c-1?"NO":"YES");}
|
a;b;main(c){scanf("%d%d%d",&a,&c,&b);puts(a+b+c==17?"YES":"NO");}
|
#include <stdio.h>
int main(void){
int A,B,C;
scanf("%d %d %d",&A,&B,&C);
puts((A*B*C==175)?"YES":"NO");
}
|
#include<stdio.h>
int main(){
int a=0,b=0,i=0,c;
for(i=0;i<3;i++){
scanf("%d ",&c);
if(c==5)a++;
if(c==7)b++;
}
if(a==2&&b==1)puts("YES");
else puts("NO");
return 0;
}
|
#include <stdio.h>
int main()
{
int A, B, C;
scanf("%d %d %d", &A, &B, &C);
if (A + B + C == 17 && A * B + B * C + C * A == 95 && A * B * C == 175) printf("YES\n");
else printf("NO\n");
fflush(stdout);
return 0;
}
|
#include <stdio.h>
int main ()
{int a,b,c,wu=0,qi=0;
scanf("%d%d%d",&a,&b,&c);
if(a==5)
wu++;
if(a==7)
qi++;
if(b==5)
wu++;
if(b==7)
qi++;
if(c==5)
wu++;
if(c==7)
qi++;
if(wu==2&&qi==1)
printf("YES");
else
printf("NO");
}
|
#include <stdio.h>
int main(){
int d[3];
int i,s;
scanf("%d %d %d",&d[0],&d[1],&d[2]);
for(i=0;i<3;i++){
if(d[i] == 5){s = s + 5 ;}
if(d[i] == 7){s = s + 7 ;}
}
if(s == 17){
printf("YES");}
else
printf("NO");
}
|
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(void){
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
int s[10]={0};
s[a]++;s[b]++;s[c]++;
if(s[5]==2&&s[7]==1) printf("YES");
else printf("NO");
return 0;
}
|
#include <stdio.h>
int t, five, seven;
int main(void)
{
int i;
for (i = 0; i < 3; ++i)
{
scanf("%d", &t);
if (t == 5) five++;
else if (t == 7) seven++;
}
printf((five == 2 && seven == 1) ? "YES" : "NO");
}
|
#include<stdio.h>
int main()
{
int ar[3];
int fiv=2;
int sev=1;
for(int i=0;i<3;i++)
{
scanf("%d",&ar[i]);
if(ar[i]==5)fiv--;
if(ar[i]==7)sev--;
}
if(fiv==0&&sev==0){
printf("YES");
}
else printf("NO");
return 0;
}
|
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<math.h>
#define INFINI 100000001
int main(){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a+b+c!=17)
printf("NO");
else
printf("YES");
}
|
#include <stdio.h>
int A,B,C;
int ok=0;
int main(){
scanf("%d %d %d",&A,&B,&C);
if(A==7&&B==5&&C==5)ok=1;
else if(A==5&&B==7&&C==5)ok=1;
else if(A==5&&B==5&&C==7)ok=1;
if(ok==0)printf("NO\n");
else printf("YES\n");
return 0;
}
|
#include<stdio.h>
int main(){
int flag=0;
int num[11]={0};
int haiku[3];
for(int i=0;i<3;i++){
int a;
scanf("%d",&a);
num[a]++;
haiku[i]=a;
}
if(num[5]==2&&num[7]==1){
printf("YES\n");
}
else printf("NO\n");
return 0;
}
|
#include<stdio.h>
int main(){
int a=0,b=0,c;
scanf("%d",&c);if(c==5)a++;if(c==7)b++;
scanf("%d",&c);if(c==5)a++;if(c==7)b++;
scanf("%d",&c);if(c==5)a++;if(c==7)b++;
if(a==2&&b==1){printf("YES");return 0;}
printf("NO");
return 0;
}
|
#include<stdio.h>
int main()
{
int n5 = 0, n7 = 0, i, A[4];
scanf("%d %d %d", &A[1], &A[2], &A[3]);
for (i = 1; i < 4; i++)
{
if (A[i] == 5)n5++;
if (A[i] == 7)n7++;
}
if (n5 == 2 && n7 == 1)printf("YES");
else printf("NO");
return 0;
}
|
#include<stdio.h>
int main(void){
int A=0,B=0,C=0,count=0;
scanf("%d %d %d",&A,&B,&C);
if(A==7||A==5)
count+=A;
if(B==7||B==5)
count+=B;
if(C==7||C==5)
count+=C;
if(count==17)
printf("YES");
else
printf("NO");
return 0;
}
|
#include<stdio.h>
int main(void)
{
int a,b,c,c5=0,c7=0;
scanf("%d%d%d",&a,&b,&c);
if(a==5)
c5++;
if(b==5)
c5++;
if(c==5)
c5++;
if((a==7 || b==7)||c==7)
c7++;
if(c5==2&&c7==1)
printf("YES\n");
else
printf("NO\n");
return 0;
}
|
#include<stdio.h>
int main(){
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if(a+b+c==17){
if(a==5&&b==5){
puts("YES");
return 0;
}
if(b==5&&c==5){
puts("YES");
return 0;
}
if(c==5&&a==5){
puts("YES");
return 0;
}
}
puts("NO");
return 0;
}
|
#include <stdio.h>
int main(void){
int go,st;
int a[3];
scanf("%i %i %i",&a[0],&a[1],&a[2]);
for(int i=0; i<3;i++){
if(a[i]==5) go++;
else if(a[i]==7) st++;
}
if(go==2 && st==1){
puts("YES");
}else{
puts("NO");
}
}
|
#include <stdio.h>
int main(){
int A,B,C;
scanf("%d %d %d",&A,&B,&C);
if(A==7 && B==5){
A=5;
B=7;
}
if(C==7 && B==5){
C=5;
B=7;
}
if(A==5 && B==7){
if(C==5) printf("YES");
else printf("NO");
return 0;
}
else printf("NO");
return 0;
}
|
#include <stdio.h>
int main(void) {
int ABC[3];
int i;
int go = 0, siti = 0;
if (scanf("%d%d%d", &ABC[0], &ABC[1], &ABC[2]) != 3) return 1;
for (i = 0; i < 3; i++) {
if (ABC[i] == 5) go++;
if (ABC[i] == 7) siti++;
}
puts(go == 2 && siti == 1 ? "YES" : "NO");
return 0;
}
|
#include<stdio.h>
int main()
{
int A,B,C,d,sum;
d=17;
scanf("%d %d %d",&A,&B,&C);
sum=(A==5||A==7)+(B==5||B==7)+(C==5||C==7);
if(sum==3)
{
if((A==7&&B==7)||(A==7&&C==7)||(B==7&&C==7))
{
printf("NO");
}
else
printf("YES");
}
else
{
printf("NO");
}
return 0;
}
|
#include<stdio.h>
int main(){
int n1, n2, n3;
scanf("%d %d %d", &n1, &n2, &n3);
if((n1!=5 && n1!=7) || (n2!=5 && n2!=7) || (n3!=5 && n3!=7)) printf("NO\n");
else if((n1==7 && n2==7) || (n1==7 && n3==7) || (n2==7 && n3==7)) printf("NO\n");
else printf("YES\n");
return 0;
}
|
#include<stdio.h>
int main()
{
int A,B,C,flag=0;
scanf("%d %d %d",&A,&B,&C);
1<=A<=10;
1<=B<=10;
1<=C<=10;
if(A==5 && B==5 && C==7) flag=1;
if(A==5 && B==7 && C==5) flag=1;
if(A==7 && B==5 && C==5) flag=1;
if(flag==1)
printf("YES\n");
else
printf("NO\n");
return 0;
}
|
#include <stdio.h>
int main()
{
int a[3];
int total = 0;
scanf("%d %d %d", &a[0], &a[1], &a[2]);
for (int x = 0; x < 3; x++) {
if (a[x] != 5 && a[x] != 7) {
break;
}
total += a[x];
}
if (total != 17) {
printf("NO");
} else {
printf("YES");
}
}
|
#include <stdio.h>
int main(){
int a[2]={0,0,0};
int flag_A=0;
int flag_B=0;
//in
scanf("%d %d %d",&a[0],&a[1],&a[2]);
//read
for(int n=0;n<3;n++){
if(a[n]==5) flag_A++;
else if(a[n]==7) flag_B++;
}
//out
if(flag_A==2&&flag_B==1) printf("YES\n");
else printf("NO\n");
}
|
#include <stdio.h>
int main(int argc, char **argv) {
int n_in = 3;
int in = 0, fcount = 0, scount = 0;
while (--n_in >= 0) {
scanf("%d",&in);
if (in == 5) ++fcount;
else if (in == 7) ++scount;
}
if (fcount == 2 && scount == 1)
printf("YES\n");
else
printf("NO\n");
}
|
#include<stdio.h>
int main(void){
int num1,num2,num3;
scanf("%d %d %d",&num1,&num2,&num3);
if(num1+num2+num3==17){
if((num1==5&&num2==5)||(num2==5&&num3==5)||(num3==5&&num1==5)){
printf("YES");
}else{
printf("NO");
}
}else{
printf("NO");
}
return 0;
}
|
#include <stdio.h>
void Check(int n, int *c5, int *c7){
if(n == 5) (*c5)++;
if(n == 7) (*c7)++;
}
int main(void){
int A, B, C, c5, c7;
scanf("%d %d %d", &A, &B, &C);
c5 = c7 = 0;
Check(A, &c5, &c7);
Check(B, &c5, &c7);
Check(C, &c5, &c7);
if(c5 == 2 && c7 == 1) printf("YES\n");
else printf("NO\n");
return 0;
}
|
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *l, const void *r)
{
return *(int*)l - *(int*)r;
}
int main()
{
int abc[3];
scanf("%d %d %d", &abc[0], &abc[1], &abc[2]);
qsort(abc, 3, sizeof(int), cmp);
if (abc[0] == 5 && abc[1] == 5 && abc[2] == 7) {
puts("YES");
}
else {
puts("NO");
}
return 0;
}
|
#include <stdio.h>
int main(void)
{
char str[100];
int judge = 0;
fgets(str,100,stdin);
if(strcmp(str,"7 5 5\n") == 0)
judge = 1;
else if(strcmp(str,"5 7 5\n") == 0)
judge = 1;
else if(strcmp(str,"5 5 7\n") == 0)
judge = 1;
if(judge == 1)
printf("YES\n");
if(judge == 0)
printf("NO\n");
return 0;
}
|
#include <stdio.h>
int main(void)
{
int ABC[3];
int count7;
int count5;
count7 = 0;
count5 = 0;
scanf("%d %d %d",&ABC[0], &ABC[1], &ABC[2]);
for (int i = 0; i < 3; i++)
{
if (ABC[i] == 7)
count7++;
else if (ABC[i] == 5)
count5++;
}
if (count5 == 2 && count7 == 1)
printf("YES");
else
printf("NO");
return (0);
}
|
#include<stdio.h>
void main()
{
int c5=0,c7=0,i,arr[3];
scanf("%d %d %d",&arr[0],&arr[1],&arr[2]);
for(i=1;i<=3;i=i+1){
if(arr[i-1]==5){
c5=c5+1;
}
if(arr[i-1]==7){
c7=c7+1;
}
}
if(c5==2&&c7==1){
printf("YES\n");
}
else{
printf("NO\n");
}
}
|
//AC
#include<stdio.h>
#include<string.h>
int main()
{
char a[10]={};
int c,i,cnt=0,leap=0;
while(gets(a)){
c=strlen(a);
for(i=0;i<c;i++){
if(a[i]==' '){
continue;
}else if(a[i]=='5'){
cnt++;
}else if(a[i]=='7'){
leap++;
}
}if(cnt==2&&leap==1){
printf("YES\n");
}else{
printf("NO\n");
}cnt=0;leap=0;
}
}
|
#include <stdio.h>
int main(void){
int a[4]={0},i,lmt=3;
for(i=1;i<=3;i++){
scanf("%d",&a[i]);
}
for(i=1;i<=3;i++){
if(a[i]==5) {lmt--;a[i]=0;break;}
}
for(i=1;i<=3;i++){
if(a[i]==7) {lmt--;a[i]=0;break;}
}
for(i=1;i<=3;i++){
if(a[i]==5) {lmt--;a[i]=0;break;}
}
if(lmt==0) printf("YES");
else printf("NO");
return 0;
}
|
#include <stdio.h>
void Input(void);
int Operation(void);
int cnt[10];
int main(void)
{
Input();
printf("%s\n", Operation() ? "YES" : "NO");
return 0;
}
void Input(void)
{
int i, tmp;
for(i = 1; i <= 3; i++)
{
scanf("%d", &tmp);
cnt[tmp]++;
}
}
int Operation(void)
{
if(cnt[5] == 2 && cnt[7] == 1) return 1;
return 0;
}
|
#include<stdio.h>
int i,j;
int main(void)
{
int a[3],key=0,sum=0;
for(i=0;i<3;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<3;i++)
{
if(a[i]==5||a[i]==7)
{
key++;
}
}
sum=a[0]+a[1]+a[2];
if(key==3&&sum==17)
{
printf("YES");
}else{
printf("NO");
}
return 0;
}
|
#include<stdio.h>
int main(){
int a;
int cnt_5=0,cnt_7=0,i;
for(i=0;i<3;i++)
{
if(scanf("%d",&a)<0)
{
perror("error");
}
if(a==5)
cnt_5++;
else if(a==7)
cnt_7++;
}
if((cnt_5==2)&&(cnt_7==1))
{
puts("YES");
}
else
{
puts("NO");
}
}
|
#include<stdio.h>
int main()
{
int A,B,C,seven=0,five=0;
scanf("%d%d%d",&A,&B,&C);
if(A==5){
five++;
}else if(A==7){
seven++;
}
if(B==5){
five++;
}else if(B==7){
seven++;
}
if(C==5){
five++;
}else if(C==7){
seven++;
}
if(seven==1&&five==2){
printf("YES");
}else{
printf("NO");
}
return 0;
}
|
#include "stdio.h"
#include <string.h>
int main(){
int num[3];
memset(num, '\0', sizeof(num));
int five=0, seven=0;
scanf("%d %d %d", &num[0], &num[1], &num[2]);
for(int i=0; i<3; i++){
if(num[i] == 5){
five++;
}
else if(num[i] == 7){
seven++;
}
}
if(five == 2 && seven == 1) printf("YES");
else printf("NO");
return 0;
}
|
#include<stdio.h>
#include<stdlib.h>
int main(void){
int *iroha = calloc(3, sizeof(int));
scanf("%d%d%d",iroha,iroha+1,iroha+2);
int count[2]={0,0};
for(int i = 0; i < 3; i++){
if( iroha[i] == 5 )count[0] += 1;
else if( iroha[i] == 7)count[1] += 1;
}
if( count[0] == 2 && count[1] == 1)printf("YES\n");
else printf("NO\n");
free(iroha);
return 0;
}
|
#include<stdio.h>
#include<string.h>
int main()
{
int A,B,C;
int con5=0,con7=0,con=0;
scanf("%d %d %d",&A,&B,&C);
if(A==5) con5++;
else if(A==7) con7++;
else con++;
if(B==5) con5++;
else if(B==7) con7++;
else con++;
if(C==5) con5++;
else if(C==7) con7++;
else con++;
if(con==0&&con5==2&&con7==1)
printf("YES");
else printf("NO");
return 0;
}
|
#include<stdio.h>
int main()
{
int A,B,C;
int i, judge;
judge = 0;
//入力
scanf("%d %d %d", &A, &B, &C);
//判定処理1
if(A == 5 || A == 7)
judge += 1;
if(B == 5 || B == 7)
judge += 1;
if(C == 5 || C == 7)
judge += 1;
if((A+B+C) == 17)
judge += 1;
//デバッグコメント
//printf("A = %d\n", judge);
//判定+出力
if(judge == 4)
printf("YES");
else
printf("NO");
return(0);
}
|
#include <stdio.h>
#include <stdbool.h>
int Mayor(int A, int B){
return A>B? A: B;
};
bool Equal(int A, int B){
if(A == 5)
return A == B;
return false;
};
int main(){
int A, B, C, Aux;
scanf("%d%d%d", &A, &B, &C);
Aux = Mayor(C, Mayor(A, B));
if(Aux == 7 && (Equal(A, B) || Equal(B, C) || Equal (C, A)))
printf("YES\n");
else
printf("NO\n");
return 0;
}
|
#include<stdio.h>
#include<stdlib.h>
int main(){
int num_5,num_7;
int i;
char str[3][10];
num_5=num_7=0;
scanf("%s",str[0]);
scanf("%s",str[1]);
scanf("%s",str[2]);
for(i=0;i<3;i++){
if(atoi(str[i])==5){
num_5++;
}else if(atoi(str[i])==7){
num_7++;
}
}
if(num_5==2&&num_7==1){
printf("YES\n");
}else{
printf("NO\n");
}
return 0;
}
|
#include<stdio.h>
int main(void) {
int input[3];
int a, b, c;
int num5=0, num7=0;
int i;
scanf("%d %d %d", &a,&b, &c);
input[0] = a;
input[1] = b;
input[2] = c;
for (i = 0; i < 3; i++) {
if (input[i] == 5) {
num5++;
}
else if (input[i] == 7) {
num7++;
}
else {
}
}
if (num5 == 2 && num7 == 1) {
printf("YES\n");
}
else {
printf("NO\n");
}
return 0;
}
|
// A - 和風いろはちゃんイージー / Iroha and Haiku (ABC Edition)
#include <stdio.h>
int main(void) {
int n[3], n5 = 0, n7 = 0;
scanf("%d %d %d", &n[0], &n[1], &n[2]);
for (int i = 0; i < 3; i++) {
if (n[i] == 5) {
n5++;
} else if (n[i] == 7) {
n7++;
}
}
if((n5 == 2) && (n7 == 1)){
printf("YES\n");
}else{
printf("NO\n");
}
//printf("%d %d ",n5,n7);
return 0;
}
|
#include<stdio.h>
void change(int n[])
{
int i,j,temp;
for(i=0;i<3;i++){
for(j=0;j<2;j++){
if(n[j]>n[j+1]){
temp=n[j];
n[j]=n[j+1];
n[j+1]=temp;
}
}
}
}
int main(void)
{
int n[3];
int i;
for(i=0;i<3;i++)
scanf("%d",&n[i]);
change(n);
if(n[0]==5 && n[1]==5 && n[2]==7)
puts("YES");
else
puts("NO");
return 0;
}
|
#include<stdio.h>
int main() {
int a=0, b=0,c=0;
while (a<1 || a>10) {
scanf("%d", &a);
}
while (b<1 || b>10) {
scanf("%d", &b);
}
while (c<1 || c>10) {
scanf("%d", &c);
}
if (a == 7 && b == 5 && c == 5) {
printf("YES\n");
}
else if (a == 5 && b == 7 && c == 5) {
printf("YES\n");
}
else if (a == 5 && b == 5 && c == 7) {
printf("YES\n");
}
else {
printf("NO\n");
}
return 0;
}
|
#include<stdio.h>
int main(void){
int n[3];
int i;
int cnt_go = 0;
int cnt_shichi = 0;
scanf("%d %d %d", &n[0], &n[1], &n[2]);
for(i = 0; i < 3; i++){
if(n[i] == 5){
cnt_go++;
}
if(n[i] == 7){
cnt_shichi++;
}
}
if(cnt_go == 2 && cnt_shichi == 1){
puts("YES");
}
else{
puts("NO");
}
return 0;
}
|
#include <stdio.h>
int main (void){
int loop1;
int data[3];
scanf("%d %d %d",&data[0],&data[1],&data[2]);
int how_7=0;
int how_5=0;
for(loop1=0;loop1<3;loop1++){
if(data[loop1]==5){
how_5++;
}
if(data[loop1]==7){
how_7++;
}
}
if(how_5==2 && how_7==1){
printf("YES\n");
}else{
printf("NO\n");
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int A[3];
int a7,a5;
a7 = a5 = 0;
for(int i = 0;i < 3 ; i++){
scanf("%d",&A[i]);
}
for(int i = 0; i < 3;i++){
if(A[i] == 5){
a5++;
}
if(A[i] == 7){
a7++;
}
}
if(a5 == 2 && a7 == 1){
printf("YES");
}else{
printf("NO");
}
//printf("%d",A);
return 0;
}
|
#include <stdio.h>
int main(void){
int A, B, C;
scanf("%d %d %d", &A, &B, &C);
int number[3] = {A, B, C};
int answer[3] = {5, 5, 7};
int i, j, tmp;
for (i=0; i<3; i++){
for (j=i+1; j<3; j++){
if (number[i] > number[j]){
tmp = number[i];
number[i] = number[j];
number[j] = tmp;
}
}
}
if (number[0] == 5 && number[1] == 5 && number[2] == 7){
printf("YES\n");
}else{
printf("NO\n");
}
return 0;
}
|
#include<stdio.h>
int array[3], max, min, i;
int main()
{
scanf("%d %d %d",&array[0],&array[1],&array[2]);
max = array[0];
min = array[0];
for (i = 0; i <=2 ; i++){
if ( max < array[i]) max = array[i];
if ( min > array[i]) min = array[i];
}
if ( (array [0] + array[1] + array[2]== 17) && (max == 7) && (min == 5))
printf("YES");
else
printf("NO");
}
|
#include <stdio.h>
#define REP(i, n) for(i = 0; i < n; ++i)
#define FOR(i, a, b) for(i = a; i < b; ++i)
void yes_or_no(char boolean){
if(boolean){
printf("YES\n");
}else{
printf("NO\n");
}
}
int main(){
int x;
int i;
int five = 0, seven = 0;
REP(i, 3){
scanf("%d", &x);
if(x == 7) seven++;
else if(x == 5) five++;
}
yes_or_no(seven == 1 && five == 2);
return 0;
}
|
#include <stdio.h>
int main(){
int a,b,c;
int x5=0,x7=0;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
switch(a){
case 5:
x5++;
break;
case 7:
x7++;
}
switch(b){
case 5:
x5++;
break;
case 7:
x7++;
}
switch(c){
case 5:
x5++;
break;
case 7:
x7++;
}
if(x5==2 && x7==1){
printf("YES");
} else {
printf("NO");
}
}
|
#include <stdio.h>
int main(){
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
int five = 0,seven = 0;
switch (a) {
case 5:five++; break;
case 7:seven++; break;
default : break;
}
switch (b) {
case 5:five++; break;
case 7:seven++; break;
default : break;
}
switch (c) {
case 5:five++; break;
case 7:seven++; break;
default : break;
}
if(five == 2 && seven == 1){
printf("YES");
}
else{
printf("NO");
}
return 0;
}
|
#include<stdio.h>
int main(void)
{
unsigned short arr[3];
unsigned short five_count=0;
unsigned short seven_count=0;
scanf("%hu%hu%hu",&arr[0],&arr[1],&arr[2]);
for(int i=0;i<3;i++)
{
if(arr[i]==5)
{
five_count++;
}
if(arr[i]==7)
{
seven_count++;
}
}
if(five_count==2 && seven_count==1)
{
printf("YES\n");
}
else
{
printf("NO\n");
}
return 0;
}
|
#include <stdio.h>
int count_5=0,count_7=0;
void check(int word);
int main(void)
{
int word[4],i;
char str[16];
fgets(str,sizeof(str),stdin);
sscanf(str,"%d%d%d",&word[0],&word[1],&word[2]);
for (i=0;i<3;i++)
{
check(word[i]);
}
if((count_5 == 2)&&(count_7 == 1))
{
puts("YES");
}
else
{
puts("NO");
}
return 0;
}
void check(int word)
{
switch (word)
{
case 5:
count_5++;
break;
case 7:
count_7++;
break;
default:
break;
}
}
|
// Twitter@KonoLv1 2020年よりエンジニアデビュー予定
#include <stdio.h>
int main(void){
int text_size; // 文節の長さ
int text5 = 0; // 文節が5文字のカウント
int text7 = 0; // 文節が7文字のカウント
int input_date = 3; // 入力される文節数
for (int i = 0; i < input_date; i++){
scanf("%d",&text_size);
if (text_size == 5){
text5++;
}else if (text_size == 7){
text7++;
}
}
if (text5 == 2 && text7 == 1){
printf("YES");
}else{
printf("NO");
}
}
|
#include <stdio.h>
#include <stdlib.h>
int main()
{
int arr[3],i,f1=0,f3=0,f2=0,sum=0;
for(i=0;i<3;i++)
{
scanf("%d",&arr[i]);
sum+=arr[i];
}
/*for(i=0;i<2;i++)
{
if(arr[i]==5)
{
f1=1;
continue;
}
if(arr[i]==5&&f1==1)
{
f2=1;
}
if(arr[i]==7)
{
f3=1;
}*/
if(sum==17)
printf("YES");
else
printf("NO");
return 0;
}
|
#include<stdio.h>
int check(int str[]){
int se=0;
int fi=0;
for(int i=0;i<3;++i){
if(str[i]==7){
se+=1;
}
else if(str[i]==5){
fi+=1;
}
}
/*printf("%d",se);
printf("%d",fi);*/
if(se==1 && fi==2){
return 1;
}
return 0;
}
int main(){
int a,b,c,ch;
int d[3];
scanf("%d",&a);scanf("%d",&b);scanf("%d",&c);
d[0]=a;d[1]=b;d[2]=c;
/*printf("%d",d[0]);
printf("%d",d[1]);
printf("%d",d[2]);*/
ch=check(d);
if(ch==1){
printf("YES");
}
else{
printf("NO");
}
return 0;
}
|
//要は5が二つ7が一つあればよい
#include <stdio.h>
//はじめ
int main(void)
{
int num[4],i,count5=0,count7=0;
char str[16];
//数値を読み取る
fgets(str,sizeof(str),stdin);
sscanf(str,"%d%d%d",&num[0],&num[1],&num[2]);
//3回ループ
for(i=0;i<3;i++)
{
//数値を一つずつ調べる
switch (num[i])
{
//5か7ならそれぞれカウント
case 5:
count5++;
break;
case 7:
count7++;
break;
default :
break;
}
//ループここまで
}
//カウンターをチェック,結果を表示
if((count5==2)&&(count7==1))
{
printf("YES");
}
else
{
printf("NO");
}
return 0;
}
//おわり
|
#define _CRT_SECURE_NO_WARNINGS
//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
void sort(int[], int, int, int[]);
int main(void) {
#ifdef DEBUG
printf("");
#endif
int A, B, C;
int five=0, seven = 0;
scanf("%d %d %d", &A, &B, &C);
if (A == 5) {
five++;
}
else if (A == 7) {
seven++;
}
if (B == 5) {
five++;
}
else if (B == 7) {
seven++;
}
if (C == 5) {
five++;
}
else if (C == 7) {
seven++;
}
if (five == 2 && seven == 1) {
printf("YES\n");
}
else {
printf("NO\n");
}
return 0;
}
|
/// 5 7 5 5 7 5 5 7 5
/// 5 5 7 5 5 7 7 5 5 7 5 5
#include<stdio.h>
int main(){
int a,b,c;
int count;
int format[7];
scanf("%d%d%d",&a,&b,&c);
for(int i = 0;i < 6;i++){
if(i % 3 == 0)
format[i] = a;
else if(i % 3 == 1)
format[i] = b;
else format[i] = c;
}
count = 0;
for(int i = 0;i < 6;i++){
//printf("format[%d]:%d\n",i,format[i]);
if(format[i] == 5&&format[i+1] == 7&&format[i+2] == 5){
count = 1;
}
}
if(count == 1)
printf("YES\n");
else
printf("NO\n");
return 0;
}
|
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long int ll;
void swap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
ll asc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
ll desc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
ll max(ll x,ll y){return x>y?x:y;}
ll min(ll x,ll y){return x>y?y:x;}
int main(){
int abc[3],cnt5,cnt7;
cnt5=cnt7=0;
for(int i=0;i<3;i++){
scanf("%d",&abc[i]);
if(abc[i]==5){
cnt5++;
}else{
cnt7++;
}
}
if(cnt5==2&&cnt7==1){
printf("YES\n");
}else{
printf("NO\n");
}
return 0;
}
|
#include <stdio.h>
#include <stdlib.h>
#define STR_LEN 16
int main(void) {
char str[STR_LEN];
int chk[3] = {0};
int i;
char *p;
int five=0,seven=0;
p = fgets(str, STR_LEN, stdin);
for(i=0;i<STR_LEN;i++){
if(str[i] == ' '){
str[i] = '\0';
if(chk[0]) {
chk[1] = atoi(p);
chk[2] = atoi(&str[i+1]);
break;
} else {
chk[0] = atoi(str);
p = &str[i+1];
}
}
}
for(i=0;i<3;i++){
if(chk[i] == 5)
five++;
else if(chk[i] == 7)
seven++;
}
if(five == 2 && seven == 1){
printf("YES\n");
} else {
printf("NO\n");
}
return 0;
}
|
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<math.h>
#define FOR(i,a,b) for(i=(a);i<(b);i++)
#define RFOR(i,a,b) for(i=(b);i>=(a);i--)
#define REP(i,n) for(i=0;i<(n);i++)
#define RREP(i,n) for(i=(n)-1;i>=0;i--)
#define MREP(i,n,x) for(i=0;i<(n);i=x)
#define IL() while(1)
#define mLOOP(a,b) while((a)<(b))
#define MLOOP(a,b) while((a)>(b))
#define ELOOP(a,b) while((a)==(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)>(b)?(b):(a))
#define ABS(x) ((x)<0?-1*(x):(x))
#define in scanf
#define out printf
#define ll long long
#define uul unsigned long long
#define int(x) scanf("%d",&x);
#define sint(x,y) scanf("%d %d",&x,&y);
#define lint(x,y) scanf("%d\n%d",&x,&y);
#define char(x) scanf("%c",&x);
#define double(x) scanf("%lf",&x);
#define string(x,n) scanf("%s",x);
int cmp(const void *a,const void *b){
int tmp1 = *(int *)a;
int tmp2 = *(int *)b;
return tmp1-tmp2;
}
int main(){
int a[3];
int i;
REP(i,3){
int(a[i]);
}
qsort(a,3,sizeof(int),cmp);
if(a[0] == 5 && a[1] == 5 && a[2] == 7){
out("YES\n");
}else{
out("NO\n");
}
return 0;
}
|
strcmp();
char s[111][111];i;
main(j){
for(;gets(s[i++]););
qsort(s,i-1,111,strcmp);
for(;j<i;)printf(s[j++]);
}
|
c(int*a,int*b){return strcmp(a,b);}s[9999];i;j;main(){for(scanf("%*d%*d");~scanf("%s",s+i*32);)i++;for(qsort(s,i,128,c);j-i;)printf("%s",s+32*j++);}
|
#include<stdio.h>
#include<string.h>
int main(){
int n,m,r[110],i,j;
char s[110][110];
scanf("%d %*d",&n);
for(i=0;i<n;i++){
scanf("%s",s[i]);
for(j=i;j&&strcmp(s[r[j-1]],s[i])>0;j--)r[j]=r[j-1];
r[j]=i;
}
for(i=0;i<n;i++)printf("%s",s[r[i]]);
printf("\n");
return 0;
}
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int comp(const void * x, const void * y){
return strcmp(x,y);
}
int main(){
int i,j;
scanf("%d %d", &i, &j);
char s[i][j+1];
for(int m=0;m<i;++m) scanf("%s", s[m]);
qsort(s,i,sizeof(s[0]),comp);
for(int m=0;m<i;++m) printf("%s", s[m]);
return 0;
}
|
#include <stdio.h>
#include <string.h>
void swap(char* a, char* b){
char tmp[101];
strcpy(tmp,a);
strcpy(a,b);
strcpy(b,tmp);
}
int main(void){
int n,l,i;
scanf("%d%d",&n,&l);
char s[100][101];
for(i=0;i<n;i++)scanf("%s",s[i]);
for(i=0;i<n;i++){
for(int j=0;j<i;j++){
if(strcmp(s[i],s[j])<0)swap(s[i],s[j]);
}
}
for(i=0;i<n;i++)printf("%s",s[i]);
return 0;
}
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int Cmp(const void *a, const void *b){
return strcmp((const char *)a, (const char *)b);
}
void Do(int N, int L){
int i;
char S[N][L];
for(i = 0;i < N;i++) scanf("%s", S[i]);
qsort(S, N, sizeof(char) * L, Cmp);
printf("%s\n", S[0]);
}
int main(void){
int N, L;
scanf("%d %d", &N, &L);
Do(N, L);
return 0;
}
|
#include<stdio.h>
#include<string.h>
char c[103][103];
char copy[103];
int n,l;
int main(){
scanf("%d %d",&n,&l);
for(int i=1;i<=n;i++){//正在放第i张牌
scanf("%s",c[i]);
for(int j=1;j<i;j++){//打算放在j位置
if(strcmp(c[j],c[i])>0){
strcpy(copy,c[i]);
for(int k=i;k>j;k--){
strcpy(c[k],c[k-1]);
}
strcpy(c[j],copy);
break;
}
}
}
for(int k=1;k<=n;k++){
printf("%s",c[k]);
}
}
|
#include<stdio.h>
int main(void){
int n,l,i,j,f[128]={0},t,k;
char s[128][128];
scanf("%d%d",&n,&l);
for(i = 1;i <= n;i++){scanf("%s",s[i]);}
for(i = 1;i <= n;i++){
t = 0;
for(j = 1;j <= n;j++){
if(f[j]){continue;}
if(t == 0){t = j;}
for(k = 0;k < l;k++){
if(s[j][k] < s[t][k]){t = j;break;}
if(s[j][k] > s[t][k]){break;}
}
}
printf("%s",s[t]);
f[t]++;
}
printf("\n");
return 0;
}
|
#include <stdio.h>
#include <string.h>
int main(void){
int N, L, i, j;
char string[101][101], save[101];
scanf("%d %d", &N, &L);
for(i=0; i<N; i++) scanf("%s",string[i]);
for(i=0; i<N; i++){
for(j=i+1; j<N; j++){
if(strcmp(string[i],string[j]) > 0){
strcpy(save,string[i]);
strcpy(string[i],string[j]);
strcpy(string[j],save);
}
}
}
for(i=0; i<N; i++) printf("%s",string[i]);
return 0;
}
|
#include<string.h>
#include<stdio.h>
int main(){
int N,L = 0;
scanf("%d" "%d",&N,&L);
char S[N][L+1], tmp[L+1];
S[0][0] = '\0';
for(int x = 0; x<N; x++){
scanf("%s" ,S[x]);
}
for(int i = 1; i<N; i++){
for(int j = 1; j<N; j++){
if(strcmp(S[j],S[j-1])<0){
strcpy(tmp,S[j-1]);
strcpy(S[j-1],S[j]);
strcpy(S[j],tmp);
}
}
}
for(int y=0; y<N; y++){
printf("%s",S[y]);
}
return 0;
}
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int line[101],n,r,map[101];
char map3[100000];
char map2[100][101];
int c(const void *v1,const void *v2){
return strcmp((char *)v1,(char *)v2);
}
int main(void){
int l,i;
scanf("%d %d",&n,&l);
for(i=0;i<n;i++)
scanf("%s",map2[i]);
qsort(map2,n,sizeof(map2[0]),c);
for(i=0;i<n;i++)
strcat(map3,map2[i]);
printf("%s\n",map3);
return 0;
}
|
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
int n,l,x[110],w;
char s[110][110];
scanf("%d %d",&n,&l);
for(int i=0;i<n;i++){
scanf("%s",s[i]);
x[i]=i;
}
for(int i=0;i<n;i++){
for(int j=0;j<n-i-1;j++){
if(strcmp(s[x[j]],s[x[j+1]])>0){
w=x[j];
x[j]=x[j+1];
x[j+1]=w;}
}
}
for(int i=0;i<n;i++){
printf("%s",s[x[i]]);
}
return 0;
}
|
#include <stdio.h>
int main (){
int n,l;scanf("%d %d",&n,&l);
char s[101][101];for(int i = 0;i < n;i++){
scanf("%s",s[i]);
}
//文字列はsに入れてください。また、文字数はsizeまでです。
char x[101];
for (int i=0; i<n; ++i) {
for (int j=i+1; j<n; ++j) {
if (strcmp(s[i],s[j])>0) {
strcpy(x,s[i]);
strcpy(s[i],s[j]);
strcpy(s[j],x);
}else {
continue;
}
}
}
for(int i = 0;i < n;i++)
printf("%s",s[i]);
}
|
#include<stdio.h>
int n,l;
char li[100][101];
int a[100];
int le(int x,int y){
int k=0;
while(k<l){
if(li[x][k]<li[y][k])return 1;
if(li[x][k]>li[y][k])return 0;
k++;
}
return 0;
}
void q(int s,int t){
int p=a[s],i=s,j=t;
if(s<t){
while(1){
while(le(a[i],p))i++;
while(le(p,a[j]))j--;
if(i>=j)break;
a[i]^=a[j]^=a[i]^=a[j];
i++;j--;
}
q(s,i-1);q(j+1,t);
}
}
int main(){
int i;
scanf("%d %d",&n,&l);
for(i=0;i<n;i++){scanf("%s",li[i]);a[i]=i;}
q(0,n-1);
for(i=0;i<n;i++)printf("%s",li[a[i]]);
}
|
#include <stdio.h>
#include <string.h>
long main(void) {
int i, j;
int N, L;
if(scanf("%d", &N) < 1)return 0;
if (scanf("%d", &L) > 100)return 0;
char moji[10000][101], tmp[101];
for (i = 0; i < N; i++) {
if (scanf("%s", moji[i]) ==EOF)return 0;
}
for (i = 1; i < N; i++) {
for (j = 1; j < N; j++) {
if (strcmp(moji[j - 1], moji[j])>0) {
strcpy(tmp, moji[j - 1]);
strcpy(moji[j - 1], moji[j]);
strcpy(moji[j], tmp);
}
}
}
for (i = 0; i < N; i++) {
printf("%s", moji[i]);
}
return 0;
}
|
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int N,L;
scanf("%d %d", &N, &L);
char text[100][101],senten[10001],tem[101];
int i,j;
for(i=0; i<N; i++)
{
scanf("%s",text[i]);
}
for(i=1; i<N; i++)
{
for(j=i; j<N; j++)
{
if(strcmp(text[i-1], text[j]) > 0)
{
strcpy(tem, text[j]);
strcpy(text[j], text[i-1]);
strcpy(text[i-1], tem);
}
}
}
for(i=0; i<N; i++)
{
strcat(senten, text[i]);
}
printf("%s",senten );
return 0;
}
|
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#define REP(a) for(i = 0; i < a; i++)
int main(void)
{
int a,l,i,j;
scanf("%d%d",&a,&l);
char s[a+1][l+1],d[l];
REP(a) {
scanf("%s",s[i]);
}
REP(a) {
for(j=1;j<a;j++){
if(strcmp(s[j-1], s[j])>0){
strcpy(d, s[j-1]);
strcpy(s[j-1], s[j]);
strcpy(s[j], d);
}
}
}
REP(a) {
printf("%s",s[i]);
}
printf("\n");
return 0;
}
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
int main(int argc, char const *argv[]){
int n,l;
char str[107][107],temp[107];
scanf("%d%d\n",&n,&l);
scanf(" %s",str[0]);
for(int i = 1; i < n; ++i)
{
scanf(" %s",str[i]);
for(int j = 0; j < i; ++j)
{
if(strcmp(str[i],str[j]) < 0)
{
strcpy(temp,str[i]);
strcpy(str[i],str[j]);
strcpy(str[j],temp);
}
}
}
for(int i = 0; i < n; ++i) printf("%s",str[i]);
return 0;
}
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int comp(const void * px, const void * py){
const char* x = *(const char**)px;
const char* y = *(const char**)py;
return strcmp(x,y);
}
int main(void){
int N,L;
char **S;
scanf("%i %i", &N,&L);
S = (char**)malloc(sizeof(char*)*N);
for (int i=0; i<N; i++){
S[i] = (char*)malloc(sizeof(char)*(L+1));
scanf("%s",S[i]);
}
qsort(S,N,sizeof(char**),comp);
for(int i=0; i<N; i++){
printf("%s",S[i]);
}
free(S);
return 0;
}
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int N,L;
char str[100][101];
int cmpstr(const void * s1,const void * s2){
if(strcmp(str[*(int *)s1],str[*(int *)s2])>0)
return 1;
else if(strcmp(str[*(int *)s1],str[*(int *)s2])<0)
return -1;
else
return 0;
}
int main()
{
int strnum[100]={0};
scanf("%d %d",&N,&L);
for(int i=0;i<N;i++)
scanf("%s",str[i]);
for(int i=0;i<N;i++)
strnum[i]=i;
qsort(strnum,N,sizeof(int),cmpstr);
for(int i=0;i<N;i++)
printf("%s",str[strnum[i]]);
printf("\n");
return 0;
}
|
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
int n,l;
int i,j;
char **S;
char *min;
scanf("%d %d",&n,&l);
S=malloc(n*sizeof(char*));
for(i=0;i<n;i++){
S[i]=malloc(l*sizeof(char));
}
min=malloc(sizeof(char)*l);
for(i=0;i<n;i++){
scanf("%s",S[i]);
}
for(i=0;i<n-1;i++){
for(j=i+1;j<n;j++){
if(strcmp(S[i],S[j])>0){
strcpy(min,S[i]);
strcpy(S[i],S[j]);
strcpy(S[j],min);
}
}
}
for(i=0;i<n;i++){
printf("%s",S[i]);
}
putchar('\n');
free(S);
free(min);
return 0;
}
|
#include <stdio.h>
#include <stdlib.h>
int compara(void const *a, void const *b){
char *x = (char *)a, *y = (char *)b;
int i = 0;
while(x[i] != '\0' && y[i] != '\0'){
if(x[i] < y[i]) return -1;
if(x[i] > y[i]) return 1;
i++;
}
if(x[i] < y[i]) return -1;
if(x[i] > y[i]) return 1;
return 0;
}
int main(){
char stringe[100][111];
int n, l;
scanf("%d%d", &n, &l);
for(int i = 0; i < n; ++i) scanf(" %s", stringe[i]);
qsort(stringe, n, sizeof(stringe[0]), compara);
for(int i = 0; i < n; ++i){
int z = 0;
while(stringe[i][z] != '\0') printf("%c", stringe[i][z++]);
}
printf("\n");
}
|
#include <stdio.h>
#include <string.h>
int main (void){
int loop1;
int how_data;
int how_long;
scanf("%d %d",&how_data,&how_long);
char moji[101][101];
for(loop1=0;loop1<how_data;loop1++){
scanf("%s",moji[loop1]);
}
char temp[101];
for(loop1=0;loop1<how_data-1;loop1++){
if(strcmp(moji[loop1],moji[loop1+1])>0){
strcpy(temp,moji[loop1]);
strcpy(moji[loop1],moji[loop1+1]);
strcpy(moji[loop1+1],temp);
loop1=-1;
}
}
for(loop1=0;loop1<how_data;loop1++){
printf("%s",moji[loop1]);
}
printf("\n");
return 0;
}
|
#define _CRT_SECURE_NO_WARNINGS
//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
void sort(int[], int, int, int[]);
int main(void) {
#ifdef DEBUG
printf("");
#endif
char S[100][101];
char tmp[101];
int N, L;
int i, j, k;
scanf("%d %d", &N, &L);
for (i = 0; i < N; i++) {
scanf("%s", &S[i]);
}
for (i = 0; i < N-1; i++) {
for (j = i + 1; j < N; j++) {
k = 0;
while (S[i][k] == S[j][k]) {
k++;
}
if (S[i][k] > S[j][k]) {
strcpy(tmp,S[i]);
strcpy(S[i],S[j]);
strcpy(S[j], tmp);
}
}
}
for (i = 0; i < N; i++) {
printf("%s", S[i]);
}
printf("\n");
return 0;
}
|
#include <stdio.h>
#include <string.h>
int swap(char *a,char *b){
char tmp[101];
strcpy(tmp,b);
strcpy(b,a);
strcpy(a,tmp);
return 0;
}
int compare(char *a,char *b,int len){
int i,j;
for(i=0;i<len;i++){
if(a[i]<b[i]){
return -1;
} else if(a[i]>b[i]){
return 1;
}
}
return 0;
}
int main(){
char s[100][101];
int i,j,n,l,check;
scanf("%d %d",&n,&l);
for(i=0;i<n;i++){
scanf("%s",s[i]);
}
//compare
for(i=n;0<i;i--){
for(j=0;j<(i-1);j++){
check=compare(s[j],s[j+1],l);
if(check==1){
swap(s[j],s[j+1]);
}
}
}
for(i=0;i<n;i++){
printf("%s",s[i]);
}
}
|
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char **S;
int N,L;
char *tmp;
int flag;
scanf("%d %d",&N,&L);
S=(char**)malloc(sizeof(char*)*N);
tmp=(char*)malloc(sizeof(char)*L);
for(int i=0;i<N;i++){
S[i]=(char*)malloc(sizeof(char)*L);
scanf("%s",S[i]);
}
for(int i=0;i<N-1;i++){
for(int k=i+1;k<N;k++){
flag=0;
for(int j=0;j<L;j++){
if(S[i][j]>S[k][j]){
strcpy(tmp,S[i]);
strcpy(S[i],S[k]);
strcpy(S[k],tmp);
flag=1;
}
if(flag==1||S[i][j]<S[k][j]) break;
}
}
}
for(int i=0;i<N;i++)
printf("%s",S[i]);
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.