6616: Small Multiple

6616: Small Multiple

时间限制: 1 Sec  内存限制: 512 MB
提交: 408  解决: 61
[提交] [状态] [讨论版] [命题人:admin]

题目描述

Find the smallest possible sum of the digits in the decimal notation of a positive multiple of K.
Constraints
2≤K≤105
K is an integer.

 

 

输入

Input is given from Standard Input in the following format:
K

 

输出

Print the smallest possible sum of the digits in the decimal notation of a positive multiple of K.

 

样例输入

6

 

样例输出

3

 

提示

12=6×2 yields the smallest sum.

 

来源/分类

ABC077&ARC084 

 

[提交] [状态]

题意】求一个k的倍数使其数位和最小,输出数位和,k<=10^5。

【算法】最短路

【题解】考虑极端情况数字是可能爆long long的(例如k*num=100...000),所以确定基本方向是依次考虑答案x的每个数位。

考虑x初始是1~9,每次在后面加一位,就有x*10+0~9十种操作。

但是x可以无限大,而且x必须是k的倍数这点很难实现,综合这两点可以考虑%k。

进一步发现,%k意义下同余的数字是等价的,也就是%k等于同一个数的x只需要保留数字和最小的。

那么就可以得到算法:

k个点表示%k=0~k-1的最小数字和,起点是1~k-1(d[i]=i),终点为0,x向(x*10+0~9)%k连边权为0~9的边,跑最短路。

 

#include<bits/stdc++.h>
using namespace std;
int k,cnt,a[100004];
struct edge
{
    int to,ans,w;
} e[500004];
queue<int>q;
int dis[100004];
void add(int u,int v,int w)
{
    e[++cnt].to = v;
    e[cnt].ans = a[u];
    e[cnt].w=w;
    a[u]=cnt;
}
int main()
{
    scanf("%d",&k);
    for(int i=0; i<k; i++)
    {
        add(i,(i+1)%k,1);
        add(i,(i*10)%k,0);
    }
    q.push(1);
    memset(dis,100,sizeof(dis));
    dis[1]=0;
    while(!q.empty())
    {
        int x=q.front();
        q.pop();
        for(int i=a[x]; i; i=e[i].ans)
            if( dis[e[i].to]>dis[x]+e[i].w)
            {
                dis[e[i].to]=dis[x]+e[i].w;
                q.push(e[i].to);
            }
        }
    printf("%d\n",dis[0]+1);
    return 0;
}
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
The field of 3D point cloud semantic segmentation has been rapidly growing in recent years, with various deep learning approaches being developed to tackle this challenging task. One such approach is the U-Next framework, which has shown promising results in enhancing the semantic segmentation of 3D point clouds. The U-Next framework is a small but powerful network that is designed to extract features from point clouds and perform semantic segmentation. It is based on the U-Net architecture, which is a popular architecture used in image segmentation tasks. The U-Next framework consists of an encoder and a decoder, with skip connections between them to preserve spatial information. One of the key advantages of the U-Next framework is its ability to handle large-scale point clouds efficiently. It achieves this by using a hierarchical sampling strategy that reduces the number of points in each layer, while still preserving the overall structure of the point cloud. This allows the network to process large-scale point clouds in a more efficient manner, which is crucial for real-world applications. Another important aspect of the U-Next framework is its use of multi-scale feature fusion. This involves combining features from different scales of the point cloud to improve the accuracy of the segmentation. By fusing features from multiple scales, the network is able to capture both local and global context, which is important for accurately segmenting complex 3D scenes. Overall, the U-Next framework is a powerful tool for enhancing the semantic segmentation of 3D point clouds. Its small size and efficient processing make it ideal for real-time applications, while its multi-scale feature fusion allows it to accurately segment complex scenes. As the field of 3D point cloud semantic segmentation continues to grow, the U-Next framework is likely to play an increasingly important role in advancing this area of research.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值