以下代码为了区分题目并没有修改
package lq;
import java.util.*;
import java.math.*;
public class T1 {
static boolean judge(int x) {
int a=x*x*x;
int b=a*x;
if(a<1000||a>9999) return false;
if(b<100000||b>999999) return false;
int vis[]=new int[15];
while(a!=0) {
vis[a%10]++;
a/=10;
}
while(b!=0) {
vis[b%10]++;
b/=10;
}
for(int i=0;i<=9;i++) {
if(vis[i]!=1) return false;
}
return true;
}
public static void main(String[] args) {
for(int i=1;i<=100;i++) {
if(judge(i)) {
System.out.println(i);
break;
}
}
}
}
package lq;
public class T2 {
static long f(int x,int step) {
if(x==39&&step%2==0) return 1L;
else if(x<39) return f(x+1,step+1)+f(x+2,step+1);
else return 0;
}
static long C(int n,int m) {
if(m==0||m==n) return 1;
else return C(n-1,m)+C(n-1,m-1);
}
public static void main(String[] args) {
System.out.println(f(0,0));
long ans=0;
for(int i=0;i<=39;i++) {
for(int j=0;j<=20;j++) {
if(i+2*j==39&&(i+j)%2==0) {
ans+=C(i+j,i);
}
}
}
System.out.println(ans);
}
}
package lq;
import java.util.*;
import java.math.*;
public class T3 {
static int a[]= {2,3,4,5,6,7,8,10,12,14};
static boolean judge() {
int row=16+a[0]+a[1]+13;
int col=16+a[2]+9+a[8];
int dia=16+a[3]+a[6]+1;
if(row!=col||row!=dia||col!=dia) return false;
if(a[2]+a[3]+11+a[4]!=row||9+a[5]+a[6]+a[7]!=row||a[8]+15+a[9]+1!=row) return false;
if(a[0]+a[3]+a[5]+15!=col||a[1]+11+a[6]+a[9]!=col||13+a[4]+a[7]+1!=col) return false;
if(13+11+a[5]+a[8]!=dia) return false;
return true;
}
static void swap(int[] arr,int x,int y) {
int tmp=arr[x];
arr[x]=arr[y];
arr[y]=tmp;
}
static void fullsort(int[] arr,int begin,int end) {
if(begin+1==end) {
if(judge()) System.out.println(a[7]);
return ;
}
for(int i=begin;i
package lq;
import java.util.*;
import java.math.*;
public class T4 {
static class node{
int x,y;
}
static node pei[]=new node[10086];
static node zhuan[]=new node[10086];
static int a[]= {0,1,2,-1,-1,5,9,-1,8,6};
public static void main(String[] args) {
int t1=0,t2=0;
for(int i=1000;i<=9999;i++) {
if(i%10==0) continue;
int x=i;
int y=0;
while(x!=0&&y!=-1) {
if(a[x%10]==-1) y=-1;
else y=y*10+a[x%10];
x/=10;
}
if(y!=-1&&i-y>200&&i-y<300) {
t1++;
pei[t1]=new node();
pei[t1].x=i;
pei[t1].y=y-i;
}
if(y!=-1&&y-i>800&&y-i<900) {
t2++;
zhuan[t2]=new node();
zhuan[t2].x=i;
zhuan[t2].y=y-i;
}
}
for(int i=1;i<=t1;i++) {
for(int j=1;j<=t2;j++) {
if(pei[i].y+zhuan[j].y==558) {
System.out.println(pei[i].x);
break;
}
}
}
}
}
#include
// 交换数值
void swap(int *a,int *b)
{
int temp;
temp=*a;
*a=*b;
*b=temp;
}
void myfunc(int a, int b)
{
int m,n,r;
if(a
#include
char* prefix(char* haystack_start, char* needle_start)
{
char* haystack = haystack_start;
char* needle = needle_start;
while(*haystack && *needle){
//if(______________________________) return NULL; //填空位置
if(*haystack++!=*needle++) return NULL; //填空位置
}
if(*needle) return NULL;
return haystack_start;
}
void test(char* a,char* b){
char* p=prefix(a,b);
if(p==NULL) printf("NO\n");
else printf("%s\n",p);
}
int main(){
test("abcd","abc");
test("abcd","acb");
test("abcd","abcd");
test("abcd","");
test("","abc");
test("","");
return 0;
}
package lq;
import java.util.Scanner;
public class T7 {
static int gcd(int a,int b) {
return b!=0?gcd(b,a%b):a;
}
static int lcm(int a,int b) {
return a/gcd(a,b)*b;
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int a,b,c;
a=sc.nextInt();
b=sc.nextInt();
c=sc.nextInt();
int ans=lcm(lcm(a,b),c);
System.out.print(ans);
sc.close();
}
}
package lq;
import java.util.Scanner;
public class T8 {
static char mp[][]=new char[200][200];
static int n,m;
static void print(int x) {
int l=2*x+1;
int r=m-x*2;
if(x==n) {
int mid=(l+r)/2;
for(int i=l;i<=r;i++) {
mp[mid][i]='$';
mp[i][mid]='$';
}
return ;
}
for(int i=l+2;i<=r-2;i++) {
mp[l][i]='$';mp[r][i]='$';
mp[i][l]='$';mp[i][r]='$';
}
mp[l+1][l+2]=mp[l+2][l+2]=mp[l+2][l+1]='$';
mp[l+1][r-2]=mp[l+2][r-2]=mp[l+2][r-1]='$';
mp[r-2][l+1]=mp[r-2][l+2]=mp[r-1][l+2]='$';
mp[r-2][r-1]=mp[r-2][r-2]=mp[r-1][r-2]='$';
print(x+1);
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
m=5+4*n;
for(int i=1;i<=m;i++) {
for(int j=1;j<=m;j++) {
mp[i][j]='.';
}
}
print(0);
for(int i=1;i<=m;i++) {
for(int j=1;j<=m;j++) {
System.out.print(mp[i][j]);
}
System.out.println();
}
}
}
package lq;
import java.util.Scanner;
public class T9 {
public static void main(String[] args) {
int N=1000000;
boolean vis[]=new boolean[N+5];
for(int i=0;i<=N;i++) vis[i]=false;
vis[0]=true;
Scanner sc=new Scanner(System.in);
int a,b;
a=sc.nextInt();
b=sc.nextInt();
for(int i=a;i<=N;i++) {
if(vis[i-a]) vis[i]=true;
}
for(int i=b;i<=N;i++) {
if(vis[i-b]) vis[i]=true;
}
int ans=-1;
for(int i=N;i>0;i--) {
if(vis[i]==false) {
ans=i;
break;
}
}
System.out.println(ans);
sc.close();
}
}
package lq;
import java.util.Scanner;
public class T10 {
static int mp[][]=new int[15][15];
static boolean vis[][]=new boolean[15][15];
static int n,m,sum,ans=999999999;
static int [][] t= {{-1,0},{1,0},{0,-1},{0,1}};
static void dfs(int x,int y,int step,int sta) {
if(sta==sum/2) {
ans=Math.min(ans,step);
return ;
}
if(sta>sum/2) return ;
for(int i=0;i<4;i++) {
int tx=x+t[i][0];
int ty=y+t[i][1];
if(tx<1||tx>n||ty<1||ty>m||vis[tx][ty]==true) continue;
vis[tx][ty]=true;
dfs(tx,ty,step+1,sta+mp[tx][ty]);
vis[tx][ty]=false;
}
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
m=sc.nextInt();
n=sc.nextInt();
for(int i=1;i<=n;i++) {
for(int j=1;j<=m;j++) {
mp[i][j]=sc.nextInt();
sum+=mp[i][j];
}
}
if(sum%2!=0) System.out.println(0);
else {
vis[1][1]=true;
dfs(1,1,1,mp[1][1]);
if(ans==999999999) ans=0;
System.out.println(ans);
}
sc.close();
}
}