asatmda

2019 ICPC Asia Yinchuan Onsite| ICPC 银川现场赛 2019
N题(签到题)Rocon-Remocon-Indigo.1.2.3.apk签到题,直接输出斐波那契数列的案例即可A...
扫描右侧二维码阅读全文
24
2019/10

2019 ICPC Asia Yinchuan Onsite| ICPC 银川现场赛 2019

N题(签到题)Rocon-Remocon-Indigo.1.2.3.apk
N题
签到题,直接输出斐波那契数列的案例即可
AC代码如下

#include<bits/stdc++.h>
using namespace std;
int main(){
    cout<<"1 1 2 3 5"<<endl;
    return 0;
}

B题
B题

读懂题目就很好做了,做差|行列最小值。

#include<bits/stdc++.h>
#define MAXN 1005
using namespace std;
int n,a[MAXN][MAXN];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            scanf("%d",&a[i][j]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        {
            if(a[i][j]==-1)
            {
                printf("%d\n",a[1][j]-a[1][4]+a[i][5]);
                return 0;
            }
        }
    return 0;
}

I题
I题
按照进制转换的思想做即可(一边输入一边转换)

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
int t[maxn],A[maxn],n,m,i,len,k;
char str1[maxn], str2[maxn];
void solve(){
    k=0;
    len = strlen(str1);
    for(i=len; i>=0; i--)
        t[len-i-1] = str1[i] -(str1[i]<58 ? 48: str1[i]<97 ? 55: 61);
    while(len)
    {
        for(i=len; i>=1; i--)
        {
            t[i-1] +=t[i]%m*n;
            t[i] /= m;
        }
        A[k++] = t[0] % m;
        t[0] /=m;
        while(len>0&&!t[len-1])
            len--;
    }
    str2[k] =NULL;
    for(int i=0;i<=k-1;i++)
        str2[k-1-i] = A[i]+(A[i]<10 ? 48: A[i]<36 ? 55:61);
}

int main(){
    scanf("%d%d%s",&n,&m,str1);
    solve();
    printf("%s\n",str2);
    return 0;
}
import java.math.BigInteger;
import java.util.Scanner;
 
public class Main {
    static Scanner input = new Scanner(System.in);
    static int get_dig(char ch){
        if (ch >= '0' && ch <='9') return ch - '0';
        if (ch >= 'A' && ch <= 'Z')return ch - 'A' + 10;
        if (ch >= 'a' && ch <= 'z')return ch - 'a' + 36;
        return -1;
    }
    static char get_ch(int dig){
        if (dig >= 0 && dig <= 9)return (char)('0' + dig);
        if (dig >= 10 && dig <= 35) return (char)('A' + dig - 10);
        if (dig >= 36 && dig <= 62)return (char)('a' + dig - 36);
        return '\0';
    }
    public static void main(String [] args){
        int x = input.nextInt();
        int y = input.nextInt();
        String num = input.nextLine();
        BigInteger num10 = BigInteger.ZERO;
        for (int i=1; i < num.length();i++){
            int dig = get_dig(num.charAt(i));
            num10 = num10.multiply(BigInteger.valueOf(x)).add(BigInteger.valueOf(dig));
        }
        String ans = "";
        if (num10.compareTo(BigInteger.ZERO) == 0){
            System.out.print("0");
            return;
        }
        while (num10.compareTo(BigInteger.ZERO) > 0){
            BigInteger dig = num10.mod(BigInteger.valueOf(y));
            int digg = (int)dig.longValue();
            ans  = get_ch(digg) + ans;
            num10 = num10.divide(BigInteger.valueOf(y));
        }
        System.out.println(ans);
    }
}
Last modification:November 18th, 2019 at 08:14 pm
如果觉得我的文章对你有用,请随意赞赏

One comment

  1. 逐梦

    数据怎么来的

Leave a Comment