提交时间:2023-12-09 11:22:17
运行 ID: 114993
# include <bits/stdc++.h> using namespace std ; int p [114514] ; int dfs ( int n ) { p [1] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { int j = 1 ; while ( i - j * j >= 0 ) { p [i] = min ( p [i] , p [i - j * j] + 1 ) ; j ++ ; } } return p [n] ; } int main ( ) { int m ; cin >> m ; cout << dfs ( m ) << endl ; return 0 ; }